repo
stringlengths 7
55
| path
stringlengths 4
127
| func_name
stringlengths 1
88
| original_string
stringlengths 75
19.8k
| language
stringclasses 1
value | code
stringlengths 75
19.8k
| code_tokens
sequence | docstring
stringlengths 3
17.3k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 87
242
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
Esri/ArcREST | src/arcrest/manageags/administration.py | AGSAdministration.clusters | def clusters(self):
"""returns the clusters functions if supported in resources"""
if self._resources is None:
self.__init()
if "clusters" in self._resources:
url = self._url + "/clusters"
return _clusters.Cluster(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | python | def clusters(self):
"""returns the clusters functions if supported in resources"""
if self._resources is None:
self.__init()
if "clusters" in self._resources:
url = self._url + "/clusters"
return _clusters.Cluster(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | [
"def",
"clusters",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"if",
"\"clusters\"",
"in",
"self",
".",
"_resources",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/clusters\"",
"return",
"_clusters",
".",
"Cluster",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
"else",
":",
"return",
"None"
] | returns the clusters functions if supported in resources | [
"returns",
"the",
"clusters",
"functions",
"if",
"supported",
"in",
"resources"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/administration.py#L367-L379 | train |
Esri/ArcREST | src/arcrest/manageags/administration.py | AGSAdministration.services | def services(self):
"""
Gets the services object which will provide the ArcGIS Server's
admin information about services and folders.
"""
if self._resources is None:
self.__init()
if "services" in self._resources:
url = self._url + "/services"
return _services.Services(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | python | def services(self):
"""
Gets the services object which will provide the ArcGIS Server's
admin information about services and folders.
"""
if self._resources is None:
self.__init()
if "services" in self._resources:
url = self._url + "/services"
return _services.Services(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | [
"def",
"services",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"if",
"\"services\"",
"in",
"self",
".",
"_resources",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/services\"",
"return",
"_services",
".",
"Services",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
"else",
":",
"return",
"None"
] | Gets the services object which will provide the ArcGIS Server's
admin information about services and folders. | [
"Gets",
"the",
"services",
"object",
"which",
"will",
"provide",
"the",
"ArcGIS",
"Server",
"s",
"admin",
"information",
"about",
"services",
"and",
"folders",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/administration.py#L382-L397 | train |
Esri/ArcREST | src/arcrest/manageags/administration.py | AGSAdministration.usagereports | def usagereports(self):
"""
Gets the services object which will provide the ArcGIS Server's
admin information about the usagereports.
"""
if self._resources is None:
self.__init()
if "usagereports" in self._resources:
url = self._url + "/usagereports"
return _usagereports.UsageReports(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | python | def usagereports(self):
"""
Gets the services object which will provide the ArcGIS Server's
admin information about the usagereports.
"""
if self._resources is None:
self.__init()
if "usagereports" in self._resources:
url = self._url + "/usagereports"
return _usagereports.UsageReports(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | [
"def",
"usagereports",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"if",
"\"usagereports\"",
"in",
"self",
".",
"_resources",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/usagereports\"",
"return",
"_usagereports",
".",
"UsageReports",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
"else",
":",
"return",
"None"
] | Gets the services object which will provide the ArcGIS Server's
admin information about the usagereports. | [
"Gets",
"the",
"services",
"object",
"which",
"will",
"provide",
"the",
"ArcGIS",
"Server",
"s",
"admin",
"information",
"about",
"the",
"usagereports",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/administration.py#L400-L415 | train |
Esri/ArcREST | src/arcrest/manageags/administration.py | AGSAdministration.kml | def kml(self):
"""returns the kml functions for server"""
url = self._url + "/kml"
return _kml.KML(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True) | python | def kml(self):
"""returns the kml functions for server"""
url = self._url + "/kml"
return _kml.KML(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True) | [
"def",
"kml",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/kml\"",
"return",
"_kml",
".",
"KML",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")"
] | returns the kml functions for server | [
"returns",
"the",
"kml",
"functions",
"for",
"server"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/administration.py#L418-L425 | train |
Esri/ArcREST | src/arcrest/manageags/administration.py | AGSAdministration.logs | def logs(self):
"""returns an object to work with the site logs"""
if self._resources is None:
self.__init()
if "logs" in self._resources:
url = self._url + "/logs"
return _logs.Log(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | python | def logs(self):
"""returns an object to work with the site logs"""
if self._resources is None:
self.__init()
if "logs" in self._resources:
url = self._url + "/logs"
return _logs.Log(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | [
"def",
"logs",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"if",
"\"logs\"",
"in",
"self",
".",
"_resources",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/logs\"",
"return",
"_logs",
".",
"Log",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
"else",
":",
"return",
"None"
] | returns an object to work with the site logs | [
"returns",
"an",
"object",
"to",
"work",
"with",
"the",
"site",
"logs"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/administration.py#L428-L440 | train |
Esri/ArcREST | src/arcrest/manageags/administration.py | AGSAdministration.mode | def mode(self):
"""returns an object to work with the site mode"""
if self._resources is None:
self.__init()
if "mode" in self._resources:
url = self._url + "/mode"
return _mode.Mode(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | python | def mode(self):
"""returns an object to work with the site mode"""
if self._resources is None:
self.__init()
if "mode" in self._resources:
url = self._url + "/mode"
return _mode.Mode(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | [
"def",
"mode",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"if",
"\"mode\"",
"in",
"self",
".",
"_resources",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/mode\"",
"return",
"_mode",
".",
"Mode",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
"else",
":",
"return",
"None"
] | returns an object to work with the site mode | [
"returns",
"an",
"object",
"to",
"work",
"with",
"the",
"site",
"mode"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/administration.py#L443-L455 | train |
Esri/ArcREST | src/arcrest/manageags/administration.py | AGSAdministration.security | def security(self):
"""returns an object to work with the site security"""
if self._resources is None:
self.__init()
if "security" in self._resources:
url = self._url + "/security"
return _security.Security(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | python | def security(self):
"""returns an object to work with the site security"""
if self._resources is None:
self.__init()
if "security" in self._resources:
url = self._url + "/security"
return _security.Security(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | [
"def",
"security",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"if",
"\"security\"",
"in",
"self",
".",
"_resources",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/security\"",
"return",
"_security",
".",
"Security",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
"else",
":",
"return",
"None"
] | returns an object to work with the site security | [
"returns",
"an",
"object",
"to",
"work",
"with",
"the",
"site",
"security"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/administration.py#L458-L470 | train |
Esri/ArcREST | src/arcrest/manageags/administration.py | AGSAdministration.system | def system(self):
"""returns an object to work with the site system"""
if self._resources is None:
self.__init()
if "system" in self._resources:
url = self._url + "/system"
return _system.System(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | python | def system(self):
"""returns an object to work with the site system"""
if self._resources is None:
self.__init()
if "system" in self._resources:
url = self._url + "/system"
return _system.System(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | [
"def",
"system",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"if",
"\"system\"",
"in",
"self",
".",
"_resources",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/system\"",
"return",
"_system",
".",
"System",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
"else",
":",
"return",
"None"
] | returns an object to work with the site system | [
"returns",
"an",
"object",
"to",
"work",
"with",
"the",
"site",
"system"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/administration.py#L473-L485 | train |
Esri/ArcREST | src/arcrest/manageags/administration.py | AGSAdministration.uploads | def uploads(self):
"""returns an object to work with the site uploads"""
if self._resources is None:
self.__init()
if "uploads" in self._resources:
url = self._url + "/uploads"
return _uploads.Uploads(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | python | def uploads(self):
"""returns an object to work with the site uploads"""
if self._resources is None:
self.__init()
if "uploads" in self._resources:
url = self._url + "/uploads"
return _uploads.Uploads(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True)
else:
return None | [
"def",
"uploads",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"if",
"\"uploads\"",
"in",
"self",
".",
"_resources",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/uploads\"",
"return",
"_uploads",
".",
"Uploads",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
"else",
":",
"return",
"None"
] | returns an object to work with the site uploads | [
"returns",
"an",
"object",
"to",
"work",
"with",
"the",
"site",
"uploads"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/administration.py#L488-L500 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | Community.getGroupIDs | def getGroupIDs(self, groupNames,communityInfo=None):
"""
This function retrieves the group IDs
Inputs:
group_names - tuple of group names
Output:
dict - list of group IDs
"""
group_ids=[]
if communityInfo is None:
communityInfo = self.communitySelf
if isinstance(groupNames,list):
groupNames = map(str.upper, groupNames)
else:
groupNames = groupNames.upper()
if 'groups' in communityInfo:
for gp in communityInfo['groups']:
if str(gp['title']).upper() in groupNames:
group_ids.append(gp['id'])
del communityInfo
return group_ids | python | def getGroupIDs(self, groupNames,communityInfo=None):
"""
This function retrieves the group IDs
Inputs:
group_names - tuple of group names
Output:
dict - list of group IDs
"""
group_ids=[]
if communityInfo is None:
communityInfo = self.communitySelf
if isinstance(groupNames,list):
groupNames = map(str.upper, groupNames)
else:
groupNames = groupNames.upper()
if 'groups' in communityInfo:
for gp in communityInfo['groups']:
if str(gp['title']).upper() in groupNames:
group_ids.append(gp['id'])
del communityInfo
return group_ids | [
"def",
"getGroupIDs",
"(",
"self",
",",
"groupNames",
",",
"communityInfo",
"=",
"None",
")",
":",
"group_ids",
"=",
"[",
"]",
"if",
"communityInfo",
"is",
"None",
":",
"communityInfo",
"=",
"self",
".",
"communitySelf",
"if",
"isinstance",
"(",
"groupNames",
",",
"list",
")",
":",
"groupNames",
"=",
"map",
"(",
"str",
".",
"upper",
",",
"groupNames",
")",
"else",
":",
"groupNames",
"=",
"groupNames",
".",
"upper",
"(",
")",
"if",
"'groups'",
"in",
"communityInfo",
":",
"for",
"gp",
"in",
"communityInfo",
"[",
"'groups'",
"]",
":",
"if",
"str",
"(",
"gp",
"[",
"'title'",
"]",
")",
".",
"upper",
"(",
")",
"in",
"groupNames",
":",
"group_ids",
".",
"append",
"(",
"gp",
"[",
"'id'",
"]",
")",
"del",
"communityInfo",
"return",
"group_ids"
] | This function retrieves the group IDs
Inputs:
group_names - tuple of group names
Output:
dict - list of group IDs | [
"This",
"function",
"retrieves",
"the",
"group",
"IDs"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L119-L143 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | Community.groups | def groups(self):
""" returns the group object """
return Groups(url="%s/groups" % self.root,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initalize=False) | python | def groups(self):
""" returns the group object """
return Groups(url="%s/groups" % self.root,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initalize=False) | [
"def",
"groups",
"(",
"self",
")",
":",
"return",
"Groups",
"(",
"url",
"=",
"\"%s/groups\"",
"%",
"self",
".",
"root",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initalize",
"=",
"False",
")"
] | returns the group object | [
"returns",
"the",
"group",
"object"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L250-L256 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | Groups.group | def group(self, groupId):
"""
gets a group based on it's ID
"""
url = "%s/%s" % (self.root, groupId)
return Group(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initalize=False) | python | def group(self, groupId):
"""
gets a group based on it's ID
"""
url = "%s/%s" % (self.root, groupId)
return Group(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initalize=False) | [
"def",
"group",
"(",
"self",
",",
"groupId",
")",
":",
"url",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"root",
",",
"groupId",
")",
"return",
"Group",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initalize",
"=",
"False",
")"
] | gets a group based on it's ID | [
"gets",
"a",
"group",
"based",
"on",
"it",
"s",
"ID"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L399-L408 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | Group.invite | def invite(self, users, role, expiration=1440):
"""
A group administrator can invite users to join their group using
the Invite to Group operation. This creates a new user invitation,
which the users accept or decline. The role of the user and the
invitation expiration date can be set in the invitation.
A notification is created for the user indicating that they were
invited to join the group. Available only to authenticated users.
Inputs:
users - A comma separated list of usernames to be invited to the
group. If a user is already a member of the group or an
invitation has already been sent, the call still returns
a success.
Example: users=regularusername1,regularusername2
role - Allows administrators to set the user's role in the group
Roles are:
group_member: Ability to view and share items with
group.
group_admin: In addition to viewing and sharing items,
the group_admin has the same capabilities
as the group owner-invite users to the
group, accept or decline group
applications, delete content, and remove
users.
expiration - Expiration date on the invitation can be set for
one day, three days, one week, or two weeks, in
minutes. Default is 1440
"""
params = {
"f" : "json",
"users" : users,
"role" : role,
"expiration" : expiration
}
return self._post(url=self._url + "/invite",
securityHandler=self._securityHandler,
param_dict=params,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def invite(self, users, role, expiration=1440):
"""
A group administrator can invite users to join their group using
the Invite to Group operation. This creates a new user invitation,
which the users accept or decline. The role of the user and the
invitation expiration date can be set in the invitation.
A notification is created for the user indicating that they were
invited to join the group. Available only to authenticated users.
Inputs:
users - A comma separated list of usernames to be invited to the
group. If a user is already a member of the group or an
invitation has already been sent, the call still returns
a success.
Example: users=regularusername1,regularusername2
role - Allows administrators to set the user's role in the group
Roles are:
group_member: Ability to view and share items with
group.
group_admin: In addition to viewing and sharing items,
the group_admin has the same capabilities
as the group owner-invite users to the
group, accept or decline group
applications, delete content, and remove
users.
expiration - Expiration date on the invitation can be set for
one day, three days, one week, or two weeks, in
minutes. Default is 1440
"""
params = {
"f" : "json",
"users" : users,
"role" : role,
"expiration" : expiration
}
return self._post(url=self._url + "/invite",
securityHandler=self._securityHandler,
param_dict=params,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"invite",
"(",
"self",
",",
"users",
",",
"role",
",",
"expiration",
"=",
"1440",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"users\"",
":",
"users",
",",
"\"role\"",
":",
"role",
",",
"\"expiration\"",
":",
"expiration",
"}",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/invite\"",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"param_dict",
"=",
"params",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | A group administrator can invite users to join their group using
the Invite to Group operation. This creates a new user invitation,
which the users accept or decline. The role of the user and the
invitation expiration date can be set in the invitation.
A notification is created for the user indicating that they were
invited to join the group. Available only to authenticated users.
Inputs:
users - A comma separated list of usernames to be invited to the
group. If a user is already a member of the group or an
invitation has already been sent, the call still returns
a success.
Example: users=regularusername1,regularusername2
role - Allows administrators to set the user's role in the group
Roles are:
group_member: Ability to view and share items with
group.
group_admin: In addition to viewing and sharing items,
the group_admin has the same capabilities
as the group owner-invite users to the
group, accept or decline group
applications, delete content, and remove
users.
expiration - Expiration date on the invitation can be set for
one day, three days, one week, or two weeks, in
minutes. Default is 1440 | [
"A",
"group",
"administrator",
"can",
"invite",
"users",
"to",
"join",
"their",
"group",
"using",
"the",
"Invite",
"to",
"Group",
"operation",
".",
"This",
"creates",
"a",
"new",
"user",
"invitation",
"which",
"the",
"users",
"accept",
"or",
"decline",
".",
"The",
"role",
"of",
"the",
"user",
"and",
"the",
"invitation",
"expiration",
"date",
"can",
"be",
"set",
"in",
"the",
"invitation",
".",
"A",
"notification",
"is",
"created",
"for",
"the",
"user",
"indicating",
"that",
"they",
"were",
"invited",
"to",
"join",
"the",
"group",
".",
"Available",
"only",
"to",
"authenticated",
"users",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L861-L900 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | Group.applications | def applications(self):
"""returns all the group applications to join"""
url = self._url + "/applications"
params = {"f" : "json"}
res = self._get(url=url,
param_dict=params,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
items = []
if "applications" in res.keys():
for apps in res['applications']:
items.append(
self.Application(url="%s/%s" % (self._url, apps['username']),
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
)
return items | python | def applications(self):
"""returns all the group applications to join"""
url = self._url + "/applications"
params = {"f" : "json"}
res = self._get(url=url,
param_dict=params,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
items = []
if "applications" in res.keys():
for apps in res['applications']:
items.append(
self.Application(url="%s/%s" % (self._url, apps['username']),
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
)
return items | [
"def",
"applications",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/applications\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"res",
"=",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"items",
"=",
"[",
"]",
"if",
"\"applications\"",
"in",
"res",
".",
"keys",
"(",
")",
":",
"for",
"apps",
"in",
"res",
"[",
"'applications'",
"]",
":",
"items",
".",
"append",
"(",
"self",
".",
"Application",
"(",
"url",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"_url",
",",
"apps",
"[",
"'username'",
"]",
")",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
")",
"return",
"items"
] | returns all the group applications to join | [
"returns",
"all",
"the",
"group",
"applications",
"to",
"join"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L987-L1004 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | Users.search | def search(self,
q,
start=1,
num=10,
sortField="username",
sortOrder="asc"):
"""
The User Search operation searches for users in the portal. The
search index is updated whenever users are created, updated, or
deleted. There can be a lag between the time that the user is
updated and the time when it's reflected in the search results. The
results only contain users that the calling user has permissions to
see. Users can control this visibility by changing the access
property of their user.
Inputs:
q -The query string to search the users against.
start - The number of the first entry in the result set response.
The index number is 1-based. The default value of start is
1 (for example, the first search result). The start
parameter, along with the num parameter can be used to
paginate the search results.
num - The maximum number of results to be included in the result
set response. The default value is 10, and the maximum
allowed value is 100. The start parameter, along with the num
parameter can be used to paginate the search results. The
actual number of returned results may be less than num. This
happens when the number of results remaining after start is
less than num.
sortField - Field to sort by. The allowed field names are username
and created.
sortOrder - Describes whether the returned results are in ascending
or descending order. Default is ascending.
Values: asc | desc
"""
params = {
"f" : "json",
"q" : q,
"start" : start,
"num" : num,
"sortField" : sortField,
"sortOrder" : sortOrder
}
url = self._url
return self._get(
url = url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def search(self,
q,
start=1,
num=10,
sortField="username",
sortOrder="asc"):
"""
The User Search operation searches for users in the portal. The
search index is updated whenever users are created, updated, or
deleted. There can be a lag between the time that the user is
updated and the time when it's reflected in the search results. The
results only contain users that the calling user has permissions to
see. Users can control this visibility by changing the access
property of their user.
Inputs:
q -The query string to search the users against.
start - The number of the first entry in the result set response.
The index number is 1-based. The default value of start is
1 (for example, the first search result). The start
parameter, along with the num parameter can be used to
paginate the search results.
num - The maximum number of results to be included in the result
set response. The default value is 10, and the maximum
allowed value is 100. The start parameter, along with the num
parameter can be used to paginate the search results. The
actual number of returned results may be less than num. This
happens when the number of results remaining after start is
less than num.
sortField - Field to sort by. The allowed field names are username
and created.
sortOrder - Describes whether the returned results are in ascending
or descending order. Default is ascending.
Values: asc | desc
"""
params = {
"f" : "json",
"q" : q,
"start" : start,
"num" : num,
"sortField" : sortField,
"sortOrder" : sortOrder
}
url = self._url
return self._get(
url = url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"search",
"(",
"self",
",",
"q",
",",
"start",
"=",
"1",
",",
"num",
"=",
"10",
",",
"sortField",
"=",
"\"username\"",
",",
"sortOrder",
"=",
"\"asc\"",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"q\"",
":",
"q",
",",
"\"start\"",
":",
"start",
",",
"\"num\"",
":",
"num",
",",
"\"sortField\"",
":",
"sortField",
",",
"\"sortOrder\"",
":",
"sortOrder",
"}",
"url",
"=",
"self",
".",
"_url",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | The User Search operation searches for users in the portal. The
search index is updated whenever users are created, updated, or
deleted. There can be a lag between the time that the user is
updated and the time when it's reflected in the search results. The
results only contain users that the calling user has permissions to
see. Users can control this visibility by changing the access
property of their user.
Inputs:
q -The query string to search the users against.
start - The number of the first entry in the result set response.
The index number is 1-based. The default value of start is
1 (for example, the first search result). The start
parameter, along with the num parameter can be used to
paginate the search results.
num - The maximum number of results to be included in the result
set response. The default value is 10, and the maximum
allowed value is 100. The start parameter, along with the num
parameter can be used to paginate the search results. The
actual number of returned results may be less than num. This
happens when the number of results remaining after start is
less than num.
sortField - Field to sort by. The allowed field names are username
and created.
sortOrder - Describes whether the returned results are in ascending
or descending order. Default is ascending.
Values: asc | desc | [
"The",
"User",
"Search",
"operation",
"searches",
"for",
"users",
"in",
"the",
"portal",
".",
"The",
"search",
"index",
"is",
"updated",
"whenever",
"users",
"are",
"created",
"updated",
"or",
"deleted",
".",
"There",
"can",
"be",
"a",
"lag",
"between",
"the",
"time",
"that",
"the",
"user",
"is",
"updated",
"and",
"the",
"time",
"when",
"it",
"s",
"reflected",
"in",
"the",
"search",
"results",
".",
"The",
"results",
"only",
"contain",
"users",
"that",
"the",
"calling",
"user",
"has",
"permissions",
"to",
"see",
".",
"Users",
"can",
"control",
"this",
"visibility",
"by",
"changing",
"the",
"access",
"property",
"of",
"their",
"user",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L1157-L1206 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | Users.__getUsername | def __getUsername(self):
"""tries to parse the user name from various objects"""
if self._securityHandler is not None and \
not self._securityHandler._username is None:
return self._securityHandler._username
elif self._securityHandler is not None and \
hasattr(self._securityHandler, "org_url") and \
self._securityHandler.org_url is not None:
from .administration import Administration
user = Administration(url=self._securityHandler.org_url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port).portals.portalSelf.user
return user['username']
else:
from .administration import Administration
url = self._url.lower().split('/content/')[0]
user = Administration(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port).portals.portalSelf.user
return user['username'] | python | def __getUsername(self):
"""tries to parse the user name from various objects"""
if self._securityHandler is not None and \
not self._securityHandler._username is None:
return self._securityHandler._username
elif self._securityHandler is not None and \
hasattr(self._securityHandler, "org_url") and \
self._securityHandler.org_url is not None:
from .administration import Administration
user = Administration(url=self._securityHandler.org_url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port).portals.portalSelf.user
return user['username']
else:
from .administration import Administration
url = self._url.lower().split('/content/')[0]
user = Administration(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port).portals.portalSelf.user
return user['username'] | [
"def",
"__getUsername",
"(",
"self",
")",
":",
"if",
"self",
".",
"_securityHandler",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"_securityHandler",
".",
"_username",
"is",
"None",
":",
"return",
"self",
".",
"_securityHandler",
".",
"_username",
"elif",
"self",
".",
"_securityHandler",
"is",
"not",
"None",
"and",
"hasattr",
"(",
"self",
".",
"_securityHandler",
",",
"\"org_url\"",
")",
"and",
"self",
".",
"_securityHandler",
".",
"org_url",
"is",
"not",
"None",
":",
"from",
".",
"administration",
"import",
"Administration",
"user",
"=",
"Administration",
"(",
"url",
"=",
"self",
".",
"_securityHandler",
".",
"org_url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
".",
"portals",
".",
"portalSelf",
".",
"user",
"return",
"user",
"[",
"'username'",
"]",
"else",
":",
"from",
".",
"administration",
"import",
"Administration",
"url",
"=",
"self",
".",
"_url",
".",
"lower",
"(",
")",
".",
"split",
"(",
"'/content/'",
")",
"[",
"0",
"]",
"user",
"=",
"Administration",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
".",
"portals",
".",
"portalSelf",
".",
"user",
"return",
"user",
"[",
"'username'",
"]"
] | tries to parse the user name from various objects | [
"tries",
"to",
"parse",
"the",
"user",
"name",
"from",
"various",
"objects"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L1208-L1230 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | Users.user | def user(self, username=None):
"""A user resource that represents a registered user in the portal."""
if username is None:
username = self.__getUsername()
parsedUsername = urlparse.quote(username)
url = self.root + "/%s" % parsedUsername
return User(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False) | python | def user(self, username=None):
"""A user resource that represents a registered user in the portal."""
if username is None:
username = self.__getUsername()
parsedUsername = urlparse.quote(username)
url = self.root + "/%s" % parsedUsername
return User(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False) | [
"def",
"user",
"(",
"self",
",",
"username",
"=",
"None",
")",
":",
"if",
"username",
"is",
"None",
":",
"username",
"=",
"self",
".",
"__getUsername",
"(",
")",
"parsedUsername",
"=",
"urlparse",
".",
"quote",
"(",
"username",
")",
"url",
"=",
"self",
".",
"root",
"+",
"\"/%s\"",
"%",
"parsedUsername",
"return",
"User",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")"
] | A user resource that represents a registered user in the portal. | [
"A",
"user",
"resource",
"that",
"represents",
"a",
"registered",
"user",
"in",
"the",
"portal",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L1233-L1243 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | User.userContent | def userContent(self):
"""allows access into the individual user's content to get at the
items owned by the current user"""
replace_start = self._url.lower().find("/community/")
len_replace = len("/community/")
url = self._url.replace(self._url[replace_start:replace_start+len_replace],
'/content/')
from ._content import User as UserContent
return UserContent(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def userContent(self):
"""allows access into the individual user's content to get at the
items owned by the current user"""
replace_start = self._url.lower().find("/community/")
len_replace = len("/community/")
url = self._url.replace(self._url[replace_start:replace_start+len_replace],
'/content/')
from ._content import User as UserContent
return UserContent(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"userContent",
"(",
"self",
")",
":",
"replace_start",
"=",
"self",
".",
"_url",
".",
"lower",
"(",
")",
".",
"find",
"(",
"\"/community/\"",
")",
"len_replace",
"=",
"len",
"(",
"\"/community/\"",
")",
"url",
"=",
"self",
".",
"_url",
".",
"replace",
"(",
"self",
".",
"_url",
"[",
"replace_start",
":",
"replace_start",
"+",
"len_replace",
"]",
",",
"'/content/'",
")",
"from",
".",
"_content",
"import",
"User",
"as",
"UserContent",
"return",
"UserContent",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | allows access into the individual user's content to get at the
items owned by the current user | [
"allows",
"access",
"into",
"the",
"individual",
"user",
"s",
"content",
"to",
"get",
"at",
"the",
"items",
"owned",
"by",
"the",
"current",
"user"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L1348-L1359 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | User.invitations | def invitations(self):
"""returns a class to access the current user's invitations"""
url = "%s/invitations" % self.root
return Invitations(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def invitations(self):
"""returns a class to access the current user's invitations"""
url = "%s/invitations" % self.root
return Invitations(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"invitations",
"(",
"self",
")",
":",
"url",
"=",
"\"%s/invitations\"",
"%",
"self",
".",
"root",
"return",
"Invitations",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | returns a class to access the current user's invitations | [
"returns",
"a",
"class",
"to",
"access",
"the",
"current",
"user",
"s",
"invitations"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L1634-L1640 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | User.notifications | def notifications(self):
"""The notifications that are available for the given user.
Notifications are events that need the user's attention-application
for joining a group administered by the user, acceptance of a group
membership application, and so on. A notification is initially
marked as new. The user can mark it as read or delete the notification.
"""
params = {"f": "json"}
url = "%s/notifications" % self.root
return Notifications(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def notifications(self):
"""The notifications that are available for the given user.
Notifications are events that need the user's attention-application
for joining a group administered by the user, acceptance of a group
membership application, and so on. A notification is initially
marked as new. The user can mark it as read or delete the notification.
"""
params = {"f": "json"}
url = "%s/notifications" % self.root
return Notifications(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"notifications",
"(",
"self",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"url",
"=",
"\"%s/notifications\"",
"%",
"self",
".",
"root",
"return",
"Notifications",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | The notifications that are available for the given user.
Notifications are events that need the user's attention-application
for joining a group administered by the user, acceptance of a group
membership application, and so on. A notification is initially
marked as new. The user can mark it as read or delete the notification. | [
"The",
"notifications",
"that",
"are",
"available",
"for",
"the",
"given",
"user",
".",
"Notifications",
"are",
"events",
"that",
"need",
"the",
"user",
"s",
"attention",
"-",
"application",
"for",
"joining",
"a",
"group",
"administered",
"by",
"the",
"user",
"acceptance",
"of",
"a",
"group",
"membership",
"application",
"and",
"so",
"on",
".",
"A",
"notification",
"is",
"initially",
"marked",
"as",
"new",
".",
"The",
"user",
"can",
"mark",
"it",
"as",
"read",
"or",
"delete",
"the",
"notification",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L1643-L1655 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | User.resetPassword | def resetPassword(self, email=True):
"""
resets a users password for an account. The password will be randomly
generated and emailed by the system.
Input:
email - boolean that an email password will be sent to the
user's profile email address. The default is True.
"""
url = self.root + "/reset"
params = {
"f" : "json",
"email" : email
}
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def resetPassword(self, email=True):
"""
resets a users password for an account. The password will be randomly
generated and emailed by the system.
Input:
email - boolean that an email password will be sent to the
user's profile email address. The default is True.
"""
url = self.root + "/reset"
params = {
"f" : "json",
"email" : email
}
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"resetPassword",
"(",
"self",
",",
"email",
"=",
"True",
")",
":",
"url",
"=",
"self",
".",
"root",
"+",
"\"/reset\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"email\"",
":",
"email",
"}",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | resets a users password for an account. The password will be randomly
generated and emailed by the system.
Input:
email - boolean that an email password will be sent to the
user's profile email address. The default is True. | [
"resets",
"a",
"users",
"password",
"for",
"an",
"account",
".",
"The",
"password",
"will",
"be",
"randomly",
"generated",
"and",
"emailed",
"by",
"the",
"system",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L1692-L1711 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | User.expirePassword | def expirePassword(self,
hours="now"):
"""sets a time when a user must reset their password"""
params = {
"f" : "json"
}
expiration = -1
if isinstance(hours, str):
if expiration == "now":
expiration = -1
elif expiration == "never":
expiration = 0
else:
expiration = -1
elif isinstance(expiration, (int, long)):
dt = datetime.now() + timedelta(hours=hours)
expiration = local_time_to_online(dt=dt)
else:
expiration = -1
params['expiration'] = expiration
url = "%s/expirePassword" % self.root
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def expirePassword(self,
hours="now"):
"""sets a time when a user must reset their password"""
params = {
"f" : "json"
}
expiration = -1
if isinstance(hours, str):
if expiration == "now":
expiration = -1
elif expiration == "never":
expiration = 0
else:
expiration = -1
elif isinstance(expiration, (int, long)):
dt = datetime.now() + timedelta(hours=hours)
expiration = local_time_to_online(dt=dt)
else:
expiration = -1
params['expiration'] = expiration
url = "%s/expirePassword" % self.root
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"expirePassword",
"(",
"self",
",",
"hours",
"=",
"\"now\"",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"expiration",
"=",
"-",
"1",
"if",
"isinstance",
"(",
"hours",
",",
"str",
")",
":",
"if",
"expiration",
"==",
"\"now\"",
":",
"expiration",
"=",
"-",
"1",
"elif",
"expiration",
"==",
"\"never\"",
":",
"expiration",
"=",
"0",
"else",
":",
"expiration",
"=",
"-",
"1",
"elif",
"isinstance",
"(",
"expiration",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"dt",
"=",
"datetime",
".",
"now",
"(",
")",
"+",
"timedelta",
"(",
"hours",
"=",
"hours",
")",
"expiration",
"=",
"local_time_to_online",
"(",
"dt",
"=",
"dt",
")",
"else",
":",
"expiration",
"=",
"-",
"1",
"params",
"[",
"'expiration'",
"]",
"=",
"expiration",
"url",
"=",
"\"%s/expirePassword\"",
"%",
"self",
".",
"root",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | sets a time when a user must reset their password | [
"sets",
"a",
"time",
"when",
"a",
"user",
"must",
"reset",
"their",
"password"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L1713-L1739 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | Invitations.userInvitations | def userInvitations(self):
"""gets all user invitations"""
self.__init()
items = []
for n in self._userInvitations:
if "id" in n:
url = "%s/%s" % (self.root, n['id'])
items.append(self.Invitation(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True))
return items | python | def userInvitations(self):
"""gets all user invitations"""
self.__init()
items = []
for n in self._userInvitations:
if "id" in n:
url = "%s/%s" % (self.root, n['id'])
items.append(self.Invitation(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True))
return items | [
"def",
"userInvitations",
"(",
"self",
")",
":",
"self",
".",
"__init",
"(",
")",
"items",
"=",
"[",
"]",
"for",
"n",
"in",
"self",
".",
"_userInvitations",
":",
"if",
"\"id\"",
"in",
"n",
":",
"url",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"root",
",",
"n",
"[",
"'id'",
"]",
")",
"items",
".",
"append",
"(",
"self",
".",
"Invitation",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
")",
"return",
"items"
] | gets all user invitations | [
"gets",
"all",
"user",
"invitations"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L2169-L2181 | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | Notifications.notifications | def notifications(self):
"""gets the user's notifications"""
self.__init()
items = []
for n in self._notifications:
if "id" in n:
url = "%s/%s" % (self.root, n['id'])
items.append(self.Notification(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port))
return items | python | def notifications(self):
"""gets the user's notifications"""
self.__init()
items = []
for n in self._notifications:
if "id" in n:
url = "%s/%s" % (self.root, n['id'])
items.append(self.Notification(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port))
return items | [
"def",
"notifications",
"(",
"self",
")",
":",
"self",
".",
"__init",
"(",
")",
"items",
"=",
"[",
"]",
"for",
"n",
"in",
"self",
".",
"_notifications",
":",
"if",
"\"id\"",
"in",
"n",
":",
"url",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"root",
",",
"n",
"[",
"'id'",
"]",
")",
"items",
".",
"append",
"(",
"self",
".",
"Notification",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
")",
"return",
"items"
] | gets the user's notifications | [
"gets",
"the",
"user",
"s",
"notifications"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L2378-L2389 | train |
Esri/ArcREST | src/arcrest/common/filters.py | StatisticFilter.add | def add(self, statisticType, onStatisticField, outStatisticFieldName=None):
"""
Adds the statistics group to the filter.
outStatistics - is supported on only those layers/tables that
indicate supportsStatistics is true.
outStatisticFieldName is empty or missing, the map server assigns a
field name to the returned statistic field. A valid field name
can only contain alphanumeric characters and an underscore.
outStatisticFieldName is a reserved keyword of the underlying DBMS,
the operation can fail. Try specifying an alternative
outStatisticFieldName. When using outStatistics, the only other
parameters that can be used are groupByFieldsForStatistics,
orderByFields, time, and where.
"""
val = {
"statisticType" : statisticType,
"onStatisticField" : onStatisticField,
"outStatisticFieldName" : outStatisticFieldName
}
if outStatisticFieldName is None:
del val['outStatisticFieldName']
self._array.append(val) | python | def add(self, statisticType, onStatisticField, outStatisticFieldName=None):
"""
Adds the statistics group to the filter.
outStatistics - is supported on only those layers/tables that
indicate supportsStatistics is true.
outStatisticFieldName is empty or missing, the map server assigns a
field name to the returned statistic field. A valid field name
can only contain alphanumeric characters and an underscore.
outStatisticFieldName is a reserved keyword of the underlying DBMS,
the operation can fail. Try specifying an alternative
outStatisticFieldName. When using outStatistics, the only other
parameters that can be used are groupByFieldsForStatistics,
orderByFields, time, and where.
"""
val = {
"statisticType" : statisticType,
"onStatisticField" : onStatisticField,
"outStatisticFieldName" : outStatisticFieldName
}
if outStatisticFieldName is None:
del val['outStatisticFieldName']
self._array.append(val) | [
"def",
"add",
"(",
"self",
",",
"statisticType",
",",
"onStatisticField",
",",
"outStatisticFieldName",
"=",
"None",
")",
":",
"val",
"=",
"{",
"\"statisticType\"",
":",
"statisticType",
",",
"\"onStatisticField\"",
":",
"onStatisticField",
",",
"\"outStatisticFieldName\"",
":",
"outStatisticFieldName",
"}",
"if",
"outStatisticFieldName",
"is",
"None",
":",
"del",
"val",
"[",
"'outStatisticFieldName'",
"]",
"self",
".",
"_array",
".",
"append",
"(",
"val",
")"
] | Adds the statistics group to the filter.
outStatistics - is supported on only those layers/tables that
indicate supportsStatistics is true.
outStatisticFieldName is empty or missing, the map server assigns a
field name to the returned statistic field. A valid field name
can only contain alphanumeric characters and an underscore.
outStatisticFieldName is a reserved keyword of the underlying DBMS,
the operation can fail. Try specifying an alternative
outStatisticFieldName. When using outStatistics, the only other
parameters that can be used are groupByFieldsForStatistics,
orderByFields, time, and where. | [
"Adds",
"the",
"statistics",
"group",
"to",
"the",
"filter",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/filters.py#L24-L46 | train |
Esri/ArcREST | src/arcrest/common/filters.py | LayerDefinitionFilter.addFilter | def addFilter(self, layer_id, where=None, outFields="*"):
""" adds a layer definition filter """
import copy
f = copy.deepcopy(self._filterTemplate)
f['layerId'] = layer_id
f['outFields'] = outFields
if where is not None:
f['where'] = where
if f not in self._filter:
self._filter.append(f) | python | def addFilter(self, layer_id, where=None, outFields="*"):
""" adds a layer definition filter """
import copy
f = copy.deepcopy(self._filterTemplate)
f['layerId'] = layer_id
f['outFields'] = outFields
if where is not None:
f['where'] = where
if f not in self._filter:
self._filter.append(f) | [
"def",
"addFilter",
"(",
"self",
",",
"layer_id",
",",
"where",
"=",
"None",
",",
"outFields",
"=",
"\"*\"",
")",
":",
"import",
"copy",
"f",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"_filterTemplate",
")",
"f",
"[",
"'layerId'",
"]",
"=",
"layer_id",
"f",
"[",
"'outFields'",
"]",
"=",
"outFields",
"if",
"where",
"is",
"not",
"None",
":",
"f",
"[",
"'where'",
"]",
"=",
"where",
"if",
"f",
"not",
"in",
"self",
".",
"_filter",
":",
"self",
".",
"_filter",
".",
"append",
"(",
"f",
")"
] | adds a layer definition filter | [
"adds",
"a",
"layer",
"definition",
"filter"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/filters.py#L76-L85 | train |
Esri/ArcREST | src/arcrest/common/filters.py | LayerDefinitionFilter.removeFilter | def removeFilter(self, filter_index):
""" removes a layer filter based on position in filter list """
f = self._filter[filter_index]
self._filter.remove(f) | python | def removeFilter(self, filter_index):
""" removes a layer filter based on position in filter list """
f = self._filter[filter_index]
self._filter.remove(f) | [
"def",
"removeFilter",
"(",
"self",
",",
"filter_index",
")",
":",
"f",
"=",
"self",
".",
"_filter",
"[",
"filter_index",
"]",
"self",
".",
"_filter",
".",
"remove",
"(",
"f",
")"
] | removes a layer filter based on position in filter list | [
"removes",
"a",
"layer",
"filter",
"based",
"on",
"position",
"in",
"filter",
"list"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/filters.py#L87-L90 | train |
Esri/ArcREST | src/arcrest/common/filters.py | GeometryFilter.geometry | def geometry(self, geometry):
""" sets the geometry value """
if isinstance(geometry, AbstractGeometry):
self._geomObject = geometry
self._geomType = geometry.type
elif arcpyFound :
wkid = None
wkt = None
if (hasattr(geometry, 'spatialReference') and \
geometry.spatialReference is not None):
if (hasattr(geometry.spatialReference, 'factoryCode') and \
geometry.spatialReference.factoryCode is not None):
wkid = geometry.spatialReference.factoryCode
else:
wkt = geometry.spatialReference.exportToString()
if isinstance(geometry, arcpy.Polygon):
self._geomObject = Polygon(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryPolygon"
elif isinstance(geometry, arcpy.Point):
self._geomObject = Point(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryPoint"
elif isinstance(geometry, arcpy.Polyline):
self._geomObject = Polyline(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryPolyline"
elif isinstance(geometry, arcpy.Multipoint):
self._geomObject = MultiPoint(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryMultipoint"
else:
raise AttributeError("geometry must be a common.Geometry or arcpy.Geometry type.")
else:
raise AttributeError("geometry must be a common.Geometry or arcpy.Geometry type.") | python | def geometry(self, geometry):
""" sets the geometry value """
if isinstance(geometry, AbstractGeometry):
self._geomObject = geometry
self._geomType = geometry.type
elif arcpyFound :
wkid = None
wkt = None
if (hasattr(geometry, 'spatialReference') and \
geometry.spatialReference is not None):
if (hasattr(geometry.spatialReference, 'factoryCode') and \
geometry.spatialReference.factoryCode is not None):
wkid = geometry.spatialReference.factoryCode
else:
wkt = geometry.spatialReference.exportToString()
if isinstance(geometry, arcpy.Polygon):
self._geomObject = Polygon(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryPolygon"
elif isinstance(geometry, arcpy.Point):
self._geomObject = Point(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryPoint"
elif isinstance(geometry, arcpy.Polyline):
self._geomObject = Polyline(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryPolyline"
elif isinstance(geometry, arcpy.Multipoint):
self._geomObject = MultiPoint(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryMultipoint"
else:
raise AttributeError("geometry must be a common.Geometry or arcpy.Geometry type.")
else:
raise AttributeError("geometry must be a common.Geometry or arcpy.Geometry type.") | [
"def",
"geometry",
"(",
"self",
",",
"geometry",
")",
":",
"if",
"isinstance",
"(",
"geometry",
",",
"AbstractGeometry",
")",
":",
"self",
".",
"_geomObject",
"=",
"geometry",
"self",
".",
"_geomType",
"=",
"geometry",
".",
"type",
"elif",
"arcpyFound",
":",
"wkid",
"=",
"None",
"wkt",
"=",
"None",
"if",
"(",
"hasattr",
"(",
"geometry",
",",
"'spatialReference'",
")",
"and",
"geometry",
".",
"spatialReference",
"is",
"not",
"None",
")",
":",
"if",
"(",
"hasattr",
"(",
"geometry",
".",
"spatialReference",
",",
"'factoryCode'",
")",
"and",
"geometry",
".",
"spatialReference",
".",
"factoryCode",
"is",
"not",
"None",
")",
":",
"wkid",
"=",
"geometry",
".",
"spatialReference",
".",
"factoryCode",
"else",
":",
"wkt",
"=",
"geometry",
".",
"spatialReference",
".",
"exportToString",
"(",
")",
"if",
"isinstance",
"(",
"geometry",
",",
"arcpy",
".",
"Polygon",
")",
":",
"self",
".",
"_geomObject",
"=",
"Polygon",
"(",
"geometry",
",",
"wkid",
"=",
"wkid",
",",
"wkt",
"=",
"wkt",
")",
"self",
".",
"_geomType",
"=",
"\"esriGeometryPolygon\"",
"elif",
"isinstance",
"(",
"geometry",
",",
"arcpy",
".",
"Point",
")",
":",
"self",
".",
"_geomObject",
"=",
"Point",
"(",
"geometry",
",",
"wkid",
"=",
"wkid",
",",
"wkt",
"=",
"wkt",
")",
"self",
".",
"_geomType",
"=",
"\"esriGeometryPoint\"",
"elif",
"isinstance",
"(",
"geometry",
",",
"arcpy",
".",
"Polyline",
")",
":",
"self",
".",
"_geomObject",
"=",
"Polyline",
"(",
"geometry",
",",
"wkid",
"=",
"wkid",
",",
"wkt",
"=",
"wkt",
")",
"self",
".",
"_geomType",
"=",
"\"esriGeometryPolyline\"",
"elif",
"isinstance",
"(",
"geometry",
",",
"arcpy",
".",
"Multipoint",
")",
":",
"self",
".",
"_geomObject",
"=",
"MultiPoint",
"(",
"geometry",
",",
"wkid",
"=",
"wkid",
",",
"wkt",
"=",
"wkt",
")",
"self",
".",
"_geomType",
"=",
"\"esriGeometryMultipoint\"",
"else",
":",
"raise",
"AttributeError",
"(",
"\"geometry must be a common.Geometry or arcpy.Geometry type.\"",
")",
"else",
":",
"raise",
"AttributeError",
"(",
"\"geometry must be a common.Geometry or arcpy.Geometry type.\"",
")"
] | sets the geometry value | [
"sets",
"the",
"geometry",
"value"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/filters.py#L189-L222 | train |
Esri/ArcREST | src/arcrest/ags/_mobileservice.py | MobileService.layers | def layers(self):
"""gets the service layers"""
if self._layers is None:
self.__init()
lyrs = []
for lyr in self._layers:
url = self._url + "/%s" % lyr['id']
lyr['object'] = MobileServiceLayer(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False)
return self._layers | python | def layers(self):
"""gets the service layers"""
if self._layers is None:
self.__init()
lyrs = []
for lyr in self._layers:
url = self._url + "/%s" % lyr['id']
lyr['object'] = MobileServiceLayer(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False)
return self._layers | [
"def",
"layers",
"(",
"self",
")",
":",
"if",
"self",
".",
"_layers",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"lyrs",
"=",
"[",
"]",
"for",
"lyr",
"in",
"self",
".",
"_layers",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/%s\"",
"%",
"lyr",
"[",
"'id'",
"]",
"lyr",
"[",
"'object'",
"]",
"=",
"MobileServiceLayer",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")",
"return",
"self",
".",
"_layers"
] | gets the service layers | [
"gets",
"the",
"service",
"layers"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_mobileservice.py#L346-L358 | train |
Esri/ArcREST | src/arcrest/manageags/_clusters.py | Cluster.clusters | def clusters(self):
"""returns the cluster object for each server"""
if self._clusters is not None:
self.__init()
Cs = []
for c in self._clusters:
url = self._url + "/%s" % c['clusterName']
Cs.append(Cluster(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True))
self._clusters = Cs
return self._clusters | python | def clusters(self):
"""returns the cluster object for each server"""
if self._clusters is not None:
self.__init()
Cs = []
for c in self._clusters:
url = self._url + "/%s" % c['clusterName']
Cs.append(Cluster(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True))
self._clusters = Cs
return self._clusters | [
"def",
"clusters",
"(",
"self",
")",
":",
"if",
"self",
".",
"_clusters",
"is",
"not",
"None",
":",
"self",
".",
"__init",
"(",
")",
"Cs",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"_clusters",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/%s\"",
"%",
"c",
"[",
"'clusterName'",
"]",
"Cs",
".",
"append",
"(",
"Cluster",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
")",
"self",
".",
"_clusters",
"=",
"Cs",
"return",
"self",
".",
"_clusters"
] | returns the cluster object for each server | [
"returns",
"the",
"cluster",
"object",
"for",
"each",
"server"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_clusters.py#L184-L197 | train |
Esri/ArcREST | src/arcrest/manageags/_clusters.py | Cluster.editProtocol | def editProtocol(self, clusterProtocolObj):
"""
Updates the Cluster Protocol. This will cause the cluster to be
restarted with updated protocol configuration.
"""
if isinstance(clusterProtocolObj, ClusterProtocol): pass
else:
raise AttributeError("Invalid Input, must be a ClusterProtocal Object")
url = self._url + "/editProtocol"
params = {
"f" : "json",
"tcpClusterPort" : str(clusterProtocolObj.value['tcpClusterPort'])
}
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def editProtocol(self, clusterProtocolObj):
"""
Updates the Cluster Protocol. This will cause the cluster to be
restarted with updated protocol configuration.
"""
if isinstance(clusterProtocolObj, ClusterProtocol): pass
else:
raise AttributeError("Invalid Input, must be a ClusterProtocal Object")
url = self._url + "/editProtocol"
params = {
"f" : "json",
"tcpClusterPort" : str(clusterProtocolObj.value['tcpClusterPort'])
}
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"editProtocol",
"(",
"self",
",",
"clusterProtocolObj",
")",
":",
"if",
"isinstance",
"(",
"clusterProtocolObj",
",",
"ClusterProtocol",
")",
":",
"pass",
"else",
":",
"raise",
"AttributeError",
"(",
"\"Invalid Input, must be a ClusterProtocal Object\"",
")",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/editProtocol\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"tcpClusterPort\"",
":",
"str",
"(",
"clusterProtocolObj",
".",
"value",
"[",
"'tcpClusterPort'",
"]",
")",
"}",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | Updates the Cluster Protocol. This will cause the cluster to be
restarted with updated protocol configuration. | [
"Updates",
"the",
"Cluster",
"Protocol",
".",
"This",
"will",
"cause",
"the",
"cluster",
"to",
"be",
"restarted",
"with",
"updated",
"protocol",
"configuration",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_clusters.py#L363-L380 | train |
Esri/ArcREST | src/arcrest/ags/_geoprocessing.py | GPTask.parameters | def parameters(self):
""" returns the default parameters """
if self._parameters is None:
self.__init()
for param in self._parameters:
if not isinstance(param['defaultValue'], BaseGPObject):
if param['dataType'] == "GPFeatureRecordSetLayer":
param['defaultValue'] = GPFeatureRecordSetLayer.fromJSON(json.dumps(param))
elif param['dataType'] == "GPString":
param['defaultValue'] = GPString.fromJSON(json.dumps(param))
elif param['dataType'] == "GPLong":
param['defaultValue'] = GPLong.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDouble":
param['defaultValue'] = GPDouble.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDate":
param['defaultValue'] = GPDate.fromJSON(json.dumps(param))
elif param['dataType'] == "GPBoolean":
param['defaultValue'] = GPBoolean.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDataFile":
param['defaultValue'] = GPDataFile.fromJSON(json.dumps(param))
elif param['dataType'] == "GPLinearUnit":
param['defaultValue'] = GPLinearUnit.fromJSON(json.dumps(param))
elif param['dataType'] == "GPMultiValue":
param['defaultValue'] = GPMultiValue.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRasterData":
param['defaultValue'] = GPRasterData.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRasterDataLayer":
param['defaultValue'] = GPRasterDataLayer.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRecordSet":
param['defaultValue'] = GPRecordSet.fromJSON(json.dumps(param))
return self._parameters | python | def parameters(self):
""" returns the default parameters """
if self._parameters is None:
self.__init()
for param in self._parameters:
if not isinstance(param['defaultValue'], BaseGPObject):
if param['dataType'] == "GPFeatureRecordSetLayer":
param['defaultValue'] = GPFeatureRecordSetLayer.fromJSON(json.dumps(param))
elif param['dataType'] == "GPString":
param['defaultValue'] = GPString.fromJSON(json.dumps(param))
elif param['dataType'] == "GPLong":
param['defaultValue'] = GPLong.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDouble":
param['defaultValue'] = GPDouble.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDate":
param['defaultValue'] = GPDate.fromJSON(json.dumps(param))
elif param['dataType'] == "GPBoolean":
param['defaultValue'] = GPBoolean.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDataFile":
param['defaultValue'] = GPDataFile.fromJSON(json.dumps(param))
elif param['dataType'] == "GPLinearUnit":
param['defaultValue'] = GPLinearUnit.fromJSON(json.dumps(param))
elif param['dataType'] == "GPMultiValue":
param['defaultValue'] = GPMultiValue.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRasterData":
param['defaultValue'] = GPRasterData.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRasterDataLayer":
param['defaultValue'] = GPRasterDataLayer.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRecordSet":
param['defaultValue'] = GPRecordSet.fromJSON(json.dumps(param))
return self._parameters | [
"def",
"parameters",
"(",
"self",
")",
":",
"if",
"self",
".",
"_parameters",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"for",
"param",
"in",
"self",
".",
"_parameters",
":",
"if",
"not",
"isinstance",
"(",
"param",
"[",
"'defaultValue'",
"]",
",",
"BaseGPObject",
")",
":",
"if",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPFeatureRecordSetLayer\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPFeatureRecordSetLayer",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPString\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPString",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPLong\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPLong",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPDouble\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPDouble",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPDate\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPDate",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPBoolean\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPBoolean",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPDataFile\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPDataFile",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPLinearUnit\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPLinearUnit",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPMultiValue\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPMultiValue",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPRasterData\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPRasterData",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPRasterDataLayer\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPRasterDataLayer",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPRecordSet\"",
":",
"param",
"[",
"'defaultValue'",
"]",
"=",
"GPRecordSet",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"return",
"self",
".",
"_parameters"
] | returns the default parameters | [
"returns",
"the",
"default",
"parameters"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_geoprocessing.py#L228-L258 | train |
Esri/ArcREST | src/arcrest/ags/_geoprocessing.py | GPTask.getJob | def getJob(self, jobID):
""" returns the results or status of a job """
url = self._url + "/jobs/%s" % (jobID)
return GPJob(url=url,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url) | python | def getJob(self, jobID):
""" returns the results or status of a job """
url = self._url + "/jobs/%s" % (jobID)
return GPJob(url=url,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url) | [
"def",
"getJob",
"(",
"self",
",",
"jobID",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/jobs/%s\"",
"%",
"(",
"jobID",
")",
"return",
"GPJob",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")"
] | returns the results or status of a job | [
"returns",
"the",
"results",
"or",
"status",
"of",
"a",
"job"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_geoprocessing.py#L281-L287 | train |
Esri/ArcREST | src/arcrest/ags/_geoprocessing.py | GPTask.executeTask | def executeTask(self,
inputs,
outSR=None,
processSR=None,
returnZ=False,
returnM=False,
f="json",
method="POST"
):
"""
performs the execute task method
"""
params = {
"f" : f
}
url = self._url + "/execute"
params = { "f" : "json" }
if not outSR is None:
params['env:outSR'] = outSR
if not processSR is None:
params['end:processSR'] = processSR
params['returnZ'] = returnZ
params['returnM'] = returnM
for p in inputs:
if isinstance(p, BaseGPObject):
params[p.paramName] = p.value
del p
if method.lower() == "post":
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
else:
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def executeTask(self,
inputs,
outSR=None,
processSR=None,
returnZ=False,
returnM=False,
f="json",
method="POST"
):
"""
performs the execute task method
"""
params = {
"f" : f
}
url = self._url + "/execute"
params = { "f" : "json" }
if not outSR is None:
params['env:outSR'] = outSR
if not processSR is None:
params['end:processSR'] = processSR
params['returnZ'] = returnZ
params['returnM'] = returnM
for p in inputs:
if isinstance(p, BaseGPObject):
params[p.paramName] = p.value
del p
if method.lower() == "post":
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
else:
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"executeTask",
"(",
"self",
",",
"inputs",
",",
"outSR",
"=",
"None",
",",
"processSR",
"=",
"None",
",",
"returnZ",
"=",
"False",
",",
"returnM",
"=",
"False",
",",
"f",
"=",
"\"json\"",
",",
"method",
"=",
"\"POST\"",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"f",
"}",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/execute\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"if",
"not",
"outSR",
"is",
"None",
":",
"params",
"[",
"'env:outSR'",
"]",
"=",
"outSR",
"if",
"not",
"processSR",
"is",
"None",
":",
"params",
"[",
"'end:processSR'",
"]",
"=",
"processSR",
"params",
"[",
"'returnZ'",
"]",
"=",
"returnZ",
"params",
"[",
"'returnM'",
"]",
"=",
"returnM",
"for",
"p",
"in",
"inputs",
":",
"if",
"isinstance",
"(",
"p",
",",
"BaseGPObject",
")",
":",
"params",
"[",
"p",
".",
"paramName",
"]",
"=",
"p",
".",
"value",
"del",
"p",
"if",
"method",
".",
"lower",
"(",
")",
"==",
"\"post\"",
":",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"else",
":",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | performs the execute task method | [
"performs",
"the",
"execute",
"task",
"method"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_geoprocessing.py#L344-L382 | train |
Esri/ArcREST | src/arcrest/ags/_geoprocessing.py | GPJob._get_json | def _get_json(self, urlpart):
"""
gets the result object dictionary
"""
url = self._url + "/%s" % urlpart
params = {
"f" : "json",
}
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self.proxy_port) | python | def _get_json(self, urlpart):
"""
gets the result object dictionary
"""
url = self._url + "/%s" % urlpart
params = {
"f" : "json",
}
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self.proxy_port) | [
"def",
"_get_json",
"(",
"self",
",",
"urlpart",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/%s\"",
"%",
"urlpart",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"}",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"proxy_port",
")"
] | gets the result object dictionary | [
"gets",
"the",
"result",
"object",
"dictionary"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_geoprocessing.py#L451-L464 | train |
Esri/ArcREST | src/arcrest/ags/_geoprocessing.py | GPJob.results | def results(self):
""" returns the results """
self.__init()
for k,v in self._results.items():
param = self._get_json(v['paramUrl'])
if param['dataType'] == "GPFeatureRecordSetLayer":
self._results[k] = GPFeatureRecordSetLayer.fromJSON(json.dumps(param))
elif param['dataType'].lower().find('gpmultivalue') > -1:
self._results[k] = GPMultiValue.fromJSON(json.dumps(param))
elif param['dataType'] == "GPString":
self._results[k] = GPString.fromJSON(json.dumps(param))
elif param['dataType'] == "GPLong":
self._results[k] = GPLong.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDouble":
self._results[k] = GPDouble.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDate":
self._results[k] = GPDate.fromJSON(json.dumps(param))
elif param['dataType'] == "GPBoolean":
self._results[k] = GPBoolean.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDataFile":
self._results[k] = GPDataFile.fromJSON(json.dumps(param))
elif param['dataType'] == "GPLinearUnit":
self._results[k] = GPLinearUnit.fromJSON(json.dumps(param))
elif param['dataType'] == "GPMultiValue":
self._results[k] = GPMultiValue.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRasterData":
self._results[k] = GPRasterData.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRasterDataLayer":
self._results[k] = GPRasterDataLayer.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRecordSet":
self._results[k] = GPRecordSet.fromJSON(json.dumps(param))
return self._results | python | def results(self):
""" returns the results """
self.__init()
for k,v in self._results.items():
param = self._get_json(v['paramUrl'])
if param['dataType'] == "GPFeatureRecordSetLayer":
self._results[k] = GPFeatureRecordSetLayer.fromJSON(json.dumps(param))
elif param['dataType'].lower().find('gpmultivalue') > -1:
self._results[k] = GPMultiValue.fromJSON(json.dumps(param))
elif param['dataType'] == "GPString":
self._results[k] = GPString.fromJSON(json.dumps(param))
elif param['dataType'] == "GPLong":
self._results[k] = GPLong.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDouble":
self._results[k] = GPDouble.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDate":
self._results[k] = GPDate.fromJSON(json.dumps(param))
elif param['dataType'] == "GPBoolean":
self._results[k] = GPBoolean.fromJSON(json.dumps(param))
elif param['dataType'] == "GPDataFile":
self._results[k] = GPDataFile.fromJSON(json.dumps(param))
elif param['dataType'] == "GPLinearUnit":
self._results[k] = GPLinearUnit.fromJSON(json.dumps(param))
elif param['dataType'] == "GPMultiValue":
self._results[k] = GPMultiValue.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRasterData":
self._results[k] = GPRasterData.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRasterDataLayer":
self._results[k] = GPRasterDataLayer.fromJSON(json.dumps(param))
elif param['dataType'] == "GPRecordSet":
self._results[k] = GPRecordSet.fromJSON(json.dumps(param))
return self._results | [
"def",
"results",
"(",
"self",
")",
":",
"self",
".",
"__init",
"(",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_results",
".",
"items",
"(",
")",
":",
"param",
"=",
"self",
".",
"_get_json",
"(",
"v",
"[",
"'paramUrl'",
"]",
")",
"if",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPFeatureRecordSetLayer\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPFeatureRecordSetLayer",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
".",
"lower",
"(",
")",
".",
"find",
"(",
"'gpmultivalue'",
")",
">",
"-",
"1",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPMultiValue",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPString\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPString",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPLong\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPLong",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPDouble\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPDouble",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPDate\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPDate",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPBoolean\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPBoolean",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPDataFile\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPDataFile",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPLinearUnit\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPLinearUnit",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPMultiValue\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPMultiValue",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPRasterData\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPRasterData",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPRasterDataLayer\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPRasterDataLayer",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"elif",
"param",
"[",
"'dataType'",
"]",
"==",
"\"GPRecordSet\"",
":",
"self",
".",
"_results",
"[",
"k",
"]",
"=",
"GPRecordSet",
".",
"fromJSON",
"(",
"json",
".",
"dumps",
"(",
"param",
")",
")",
"return",
"self",
".",
"_results"
] | returns the results | [
"returns",
"the",
"results"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_geoprocessing.py#L467-L498 | train |
Esri/ArcREST | src/arcrest/ags/_geoprocessing.py | GPJob.getParameterValue | def getParameterValue(self, parameterName):
""" gets a parameter value """
if self._results is None:
self.__init()
parameter = self._results[parameterName]
return parameter | python | def getParameterValue(self, parameterName):
""" gets a parameter value """
if self._results is None:
self.__init()
parameter = self._results[parameterName]
return parameter | [
"def",
"getParameterValue",
"(",
"self",
",",
"parameterName",
")",
":",
"if",
"self",
".",
"_results",
"is",
"None",
":",
"self",
".",
"__init",
"(",
")",
"parameter",
"=",
"self",
".",
"_results",
"[",
"parameterName",
"]",
"return",
"parameter"
] | gets a parameter value | [
"gets",
"a",
"parameter",
"value"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_geoprocessing.py#L519-L524 | train |
Esri/ArcREST | src/arcrest/ags/layer.py | FeatureLayer_Depricated.parentLayer | def parentLayer(self):
""" returns information about the parent """
if self._parentLayer is None:
from ..agol.services import FeatureService
self.__init()
url = os.path.dirname(self._url)
self._parentLayer = FeatureService(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
return self._parentLayer | python | def parentLayer(self):
""" returns information about the parent """
if self._parentLayer is None:
from ..agol.services import FeatureService
self.__init()
url = os.path.dirname(self._url)
self._parentLayer = FeatureService(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
return self._parentLayer | [
"def",
"parentLayer",
"(",
"self",
")",
":",
"if",
"self",
".",
"_parentLayer",
"is",
"None",
":",
"from",
".",
".",
"agol",
".",
"services",
"import",
"FeatureService",
"self",
".",
"__init",
"(",
")",
"url",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"_url",
")",
"self",
".",
"_parentLayer",
"=",
"FeatureService",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"return",
"self",
".",
"_parentLayer"
] | returns information about the parent | [
"returns",
"information",
"about",
"the",
"parent"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/layer.py#L289-L299 | train |
Esri/ArcREST | src/arcrest/ags/layer.py | FeatureLayer_Depricated._chunks | def _chunks(self, l, n):
""" Yield n successive chunks from a list l.
"""
l.sort()
newn = int(1.0 * len(l) / n + 0.5)
for i in range(0, n-1):
yield l[i*newn:i*newn+newn]
yield l[n*newn-newn:] | python | def _chunks(self, l, n):
""" Yield n successive chunks from a list l.
"""
l.sort()
newn = int(1.0 * len(l) / n + 0.5)
for i in range(0, n-1):
yield l[i*newn:i*newn+newn]
yield l[n*newn-newn:] | [
"def",
"_chunks",
"(",
"self",
",",
"l",
",",
"n",
")",
":",
"l",
".",
"sort",
"(",
")",
"newn",
"=",
"int",
"(",
"1.0",
"*",
"len",
"(",
"l",
")",
"/",
"n",
"+",
"0.5",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"n",
"-",
"1",
")",
":",
"yield",
"l",
"[",
"i",
"*",
"newn",
":",
"i",
"*",
"newn",
"+",
"newn",
"]",
"yield",
"l",
"[",
"n",
"*",
"newn",
"-",
"newn",
":",
"]"
] | Yield n successive chunks from a list l. | [
"Yield",
"n",
"successive",
"chunks",
"from",
"a",
"list",
"l",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/layer.py#L512-L519 | train |
Esri/ArcREST | src/arcrest/ags/layer.py | FeatureLayer_Depricated.calculate | def calculate(self, where, calcExpression, sqlFormat="standard"):
"""
The calculate operation is performed on a feature service layer
resource. It updates the values of one or more fields in an
existing feature service layer based on SQL expressions or scalar
values. The calculate operation can only be used if the
supportsCalculate property of the layer is true.
Neither the Shape field nor system fields can be updated using
calculate. System fields include ObjectId and GlobalId.
See Calculate a field for more information on supported expressions
Inputs:
where - A where clause can be used to limit the updated records.
Any legal SQL where clause operating on the fields in
the layer is allowed.
calcExpression - The array of field/value info objects that
contain the field or fields to update and their
scalar values or SQL expression. Allowed types
are dictionary and list. List must be a list
of dictionary objects.
Calculation Format is as follows:
{"field" : "<field name>",
"value" : "<value>"}
sqlFormat - The SQL format for the calcExpression. It can be
either standard SQL92 (standard) or native SQL
(native). The default is standard.
Values: standard, native
Output:
JSON as string
Usage:
>>>sh = arcrest.AGOLTokenSecurityHandler("user", "pw")
>>>fl = arcrest.agol.FeatureLayer(url="someurl",
securityHandler=sh, initialize=True)
>>>print fl.calculate(where="OBJECTID < 2",
calcExpression={"field": "ZONE",
"value" : "R1"})
{'updatedFeatureCount': 1, 'success': True}
"""
url = self._url + "/calculate"
params = {
"f" : "json",
"where" : where,
}
if isinstance(calcExpression, dict):
params["calcExpression"] = json.dumps([calcExpression],
default=_date_handler)
elif isinstance(calcExpression, list):
params["calcExpression"] = json.dumps(calcExpression,
default=_date_handler)
if sqlFormat.lower() in ['native', 'standard']:
params['sqlFormat'] = sqlFormat.lower()
else:
params['sqlFormat'] = "standard"
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url) | python | def calculate(self, where, calcExpression, sqlFormat="standard"):
"""
The calculate operation is performed on a feature service layer
resource. It updates the values of one or more fields in an
existing feature service layer based on SQL expressions or scalar
values. The calculate operation can only be used if the
supportsCalculate property of the layer is true.
Neither the Shape field nor system fields can be updated using
calculate. System fields include ObjectId and GlobalId.
See Calculate a field for more information on supported expressions
Inputs:
where - A where clause can be used to limit the updated records.
Any legal SQL where clause operating on the fields in
the layer is allowed.
calcExpression - The array of field/value info objects that
contain the field or fields to update and their
scalar values or SQL expression. Allowed types
are dictionary and list. List must be a list
of dictionary objects.
Calculation Format is as follows:
{"field" : "<field name>",
"value" : "<value>"}
sqlFormat - The SQL format for the calcExpression. It can be
either standard SQL92 (standard) or native SQL
(native). The default is standard.
Values: standard, native
Output:
JSON as string
Usage:
>>>sh = arcrest.AGOLTokenSecurityHandler("user", "pw")
>>>fl = arcrest.agol.FeatureLayer(url="someurl",
securityHandler=sh, initialize=True)
>>>print fl.calculate(where="OBJECTID < 2",
calcExpression={"field": "ZONE",
"value" : "R1"})
{'updatedFeatureCount': 1, 'success': True}
"""
url = self._url + "/calculate"
params = {
"f" : "json",
"where" : where,
}
if isinstance(calcExpression, dict):
params["calcExpression"] = json.dumps([calcExpression],
default=_date_handler)
elif isinstance(calcExpression, list):
params["calcExpression"] = json.dumps(calcExpression,
default=_date_handler)
if sqlFormat.lower() in ['native', 'standard']:
params['sqlFormat'] = sqlFormat.lower()
else:
params['sqlFormat'] = "standard"
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url) | [
"def",
"calculate",
"(",
"self",
",",
"where",
",",
"calcExpression",
",",
"sqlFormat",
"=",
"\"standard\"",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/calculate\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"where\"",
":",
"where",
",",
"}",
"if",
"isinstance",
"(",
"calcExpression",
",",
"dict",
")",
":",
"params",
"[",
"\"calcExpression\"",
"]",
"=",
"json",
".",
"dumps",
"(",
"[",
"calcExpression",
"]",
",",
"default",
"=",
"_date_handler",
")",
"elif",
"isinstance",
"(",
"calcExpression",
",",
"list",
")",
":",
"params",
"[",
"\"calcExpression\"",
"]",
"=",
"json",
".",
"dumps",
"(",
"calcExpression",
",",
"default",
"=",
"_date_handler",
")",
"if",
"sqlFormat",
".",
"lower",
"(",
")",
"in",
"[",
"'native'",
",",
"'standard'",
"]",
":",
"params",
"[",
"'sqlFormat'",
"]",
"=",
"sqlFormat",
".",
"lower",
"(",
")",
"else",
":",
"params",
"[",
"'sqlFormat'",
"]",
"=",
"\"standard\"",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")"
] | The calculate operation is performed on a feature service layer
resource. It updates the values of one or more fields in an
existing feature service layer based on SQL expressions or scalar
values. The calculate operation can only be used if the
supportsCalculate property of the layer is true.
Neither the Shape field nor system fields can be updated using
calculate. System fields include ObjectId and GlobalId.
See Calculate a field for more information on supported expressions
Inputs:
where - A where clause can be used to limit the updated records.
Any legal SQL where clause operating on the fields in
the layer is allowed.
calcExpression - The array of field/value info objects that
contain the field or fields to update and their
scalar values or SQL expression. Allowed types
are dictionary and list. List must be a list
of dictionary objects.
Calculation Format is as follows:
{"field" : "<field name>",
"value" : "<value>"}
sqlFormat - The SQL format for the calcExpression. It can be
either standard SQL92 (standard) or native SQL
(native). The default is standard.
Values: standard, native
Output:
JSON as string
Usage:
>>>sh = arcrest.AGOLTokenSecurityHandler("user", "pw")
>>>fl = arcrest.agol.FeatureLayer(url="someurl",
securityHandler=sh, initialize=True)
>>>print fl.calculate(where="OBJECTID < 2",
calcExpression={"field": "ZONE",
"value" : "R1"})
{'updatedFeatureCount': 1, 'success': True} | [
"The",
"calculate",
"operation",
"is",
"performed",
"on",
"a",
"feature",
"service",
"layer",
"resource",
".",
"It",
"updates",
"the",
"values",
"of",
"one",
"or",
"more",
"fields",
"in",
"an",
"existing",
"feature",
"service",
"layer",
"based",
"on",
"SQL",
"expressions",
"or",
"scalar",
"values",
".",
"The",
"calculate",
"operation",
"can",
"only",
"be",
"used",
"if",
"the",
"supportsCalculate",
"property",
"of",
"the",
"layer",
"is",
"true",
".",
"Neither",
"the",
"Shape",
"field",
"nor",
"system",
"fields",
"can",
"be",
"updated",
"using",
"calculate",
".",
"System",
"fields",
"include",
"ObjectId",
"and",
"GlobalId",
".",
"See",
"Calculate",
"a",
"field",
"for",
"more",
"information",
"on",
"supported",
"expressions"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/layer.py#L1034-L1092 | train |
Esri/ArcREST | src/arcrest/ags/layer.py | FeatureLayer_Depricated.validateSQL | def validateSQL(self, sql, sqlType="where"):
"""
The validateSQL operation validates an SQL-92 expression or WHERE
clause.
The validateSQL operation ensures that an SQL-92 expression, such
as one written by a user through a user interface, is correct
before performing another operation that uses the expression. For
example, validateSQL can be used to validate information that is
subsequently passed in as part of the where parameter of the
calculate operation.
validateSQL also prevents SQL injection. In addition, all table and
field names used in the SQL expression or WHERE clause are
validated to ensure they are valid tables and fields.
Inputs:
sql - The SQL expression or WHERE clause to validate.
sqlType - Three SQL types are supported in validateSQL:
where (default) - Represents the custom WHERE clause the user
can compose when querying a layer or using calculate.
expression - Represents an SQL-92 expression. Currently,
expression is used as a default value expression when adding a
new field or using the calculate API.
statement - Represents the full SQL-92 statement that can be
passed directly to the database. No current ArcGIS REST API
resource or operation supports using the full SQL-92 SELECT
statement directly. It has been added to the validateSQL for
completeness.
Values: where | expression | statement
"""
url = self._url + "/validateSQL"
if not sqlType.lower() in ['where', 'expression', 'statement']:
raise Exception("Invalid Input for sqlType: %s" % sqlType)
params = {
"f" : "json",
"sql" : sql,
"sqlType" : sqlType
}
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def validateSQL(self, sql, sqlType="where"):
"""
The validateSQL operation validates an SQL-92 expression or WHERE
clause.
The validateSQL operation ensures that an SQL-92 expression, such
as one written by a user through a user interface, is correct
before performing another operation that uses the expression. For
example, validateSQL can be used to validate information that is
subsequently passed in as part of the where parameter of the
calculate operation.
validateSQL also prevents SQL injection. In addition, all table and
field names used in the SQL expression or WHERE clause are
validated to ensure they are valid tables and fields.
Inputs:
sql - The SQL expression or WHERE clause to validate.
sqlType - Three SQL types are supported in validateSQL:
where (default) - Represents the custom WHERE clause the user
can compose when querying a layer or using calculate.
expression - Represents an SQL-92 expression. Currently,
expression is used as a default value expression when adding a
new field or using the calculate API.
statement - Represents the full SQL-92 statement that can be
passed directly to the database. No current ArcGIS REST API
resource or operation supports using the full SQL-92 SELECT
statement directly. It has been added to the validateSQL for
completeness.
Values: where | expression | statement
"""
url = self._url + "/validateSQL"
if not sqlType.lower() in ['where', 'expression', 'statement']:
raise Exception("Invalid Input for sqlType: %s" % sqlType)
params = {
"f" : "json",
"sql" : sql,
"sqlType" : sqlType
}
return self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"validateSQL",
"(",
"self",
",",
"sql",
",",
"sqlType",
"=",
"\"where\"",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/validateSQL\"",
"if",
"not",
"sqlType",
".",
"lower",
"(",
")",
"in",
"[",
"'where'",
",",
"'expression'",
",",
"'statement'",
"]",
":",
"raise",
"Exception",
"(",
"\"Invalid Input for sqlType: %s\"",
"%",
"sqlType",
")",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"sql\"",
":",
"sql",
",",
"\"sqlType\"",
":",
"sqlType",
"}",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | The validateSQL operation validates an SQL-92 expression or WHERE
clause.
The validateSQL operation ensures that an SQL-92 expression, such
as one written by a user through a user interface, is correct
before performing another operation that uses the expression. For
example, validateSQL can be used to validate information that is
subsequently passed in as part of the where parameter of the
calculate operation.
validateSQL also prevents SQL injection. In addition, all table and
field names used in the SQL expression or WHERE clause are
validated to ensure they are valid tables and fields.
Inputs:
sql - The SQL expression or WHERE clause to validate.
sqlType - Three SQL types are supported in validateSQL:
where (default) - Represents the custom WHERE clause the user
can compose when querying a layer or using calculate.
expression - Represents an SQL-92 expression. Currently,
expression is used as a default value expression when adding a
new field or using the calculate API.
statement - Represents the full SQL-92 statement that can be
passed directly to the database. No current ArcGIS REST API
resource or operation supports using the full SQL-92 SELECT
statement directly. It has been added to the validateSQL for
completeness.
Values: where | expression | statement | [
"The",
"validateSQL",
"operation",
"validates",
"an",
"SQL",
"-",
"92",
"expression",
"or",
"WHERE",
"clause",
".",
"The",
"validateSQL",
"operation",
"ensures",
"that",
"an",
"SQL",
"-",
"92",
"expression",
"such",
"as",
"one",
"written",
"by",
"a",
"user",
"through",
"a",
"user",
"interface",
"is",
"correct",
"before",
"performing",
"another",
"operation",
"that",
"uses",
"the",
"expression",
".",
"For",
"example",
"validateSQL",
"can",
"be",
"used",
"to",
"validate",
"information",
"that",
"is",
"subsequently",
"passed",
"in",
"as",
"part",
"of",
"the",
"where",
"parameter",
"of",
"the",
"calculate",
"operation",
".",
"validateSQL",
"also",
"prevents",
"SQL",
"injection",
".",
"In",
"addition",
"all",
"table",
"and",
"field",
"names",
"used",
"in",
"the",
"SQL",
"expression",
"or",
"WHERE",
"clause",
"are",
"validated",
"to",
"ensure",
"they",
"are",
"valid",
"tables",
"and",
"fields",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/layer.py#L1094-L1135 | train |
Esri/ArcREST | src/arcrest/ags/layer.py | DynamicMapLayer.asDictionary | def asDictionary(self):
""" converts the object to a dictionary """
template = {"type" : self._type,
"mapLayerId" : self._mapLayerId}
if not self._gdbVersion is None and\
self._gdbVersion != "":
template['gdbVersion'] = self._gdbVersion
return template | python | def asDictionary(self):
""" converts the object to a dictionary """
template = {"type" : self._type,
"mapLayerId" : self._mapLayerId}
if not self._gdbVersion is None and\
self._gdbVersion != "":
template['gdbVersion'] = self._gdbVersion
return template | [
"def",
"asDictionary",
"(",
"self",
")",
":",
"template",
"=",
"{",
"\"type\"",
":",
"self",
".",
"_type",
",",
"\"mapLayerId\"",
":",
"self",
".",
"_mapLayerId",
"}",
"if",
"not",
"self",
".",
"_gdbVersion",
"is",
"None",
"and",
"self",
".",
"_gdbVersion",
"!=",
"\"\"",
":",
"template",
"[",
"'gdbVersion'",
"]",
"=",
"self",
".",
"_gdbVersion",
"return",
"template"
] | converts the object to a dictionary | [
"converts",
"the",
"object",
"to",
"a",
"dictionary"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/layer.py#L1214-L1221 | train |
Esri/ArcREST | src/arcrest/ags/layer.py | DynamicDataLayer.asDictionary | def asDictionary(self):
""" returns the value as a dictionary """
template = {
"type": "dataLayer",
"dataSource": self._dataSource
}
if not self._fields is None:
template['fields'] = self._fields
return template | python | def asDictionary(self):
""" returns the value as a dictionary """
template = {
"type": "dataLayer",
"dataSource": self._dataSource
}
if not self._fields is None:
template['fields'] = self._fields
return template | [
"def",
"asDictionary",
"(",
"self",
")",
":",
"template",
"=",
"{",
"\"type\"",
":",
"\"dataLayer\"",
",",
"\"dataSource\"",
":",
"self",
".",
"_dataSource",
"}",
"if",
"not",
"self",
".",
"_fields",
"is",
"None",
":",
"template",
"[",
"'fields'",
"]",
"=",
"self",
".",
"_fields",
"return",
"template"
] | returns the value as a dictionary | [
"returns",
"the",
"value",
"as",
"a",
"dictionary"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/layer.py#L1251-L1259 | train |
Esri/ArcREST | src/arcrest/ags/layer.py | DynamicDataLayer.dataSource | def dataSource(self, value):
""" sets the datasource object """
if isinstance(value, DataSource):
self._dataSource = value
else:
raise TypeError("value must be a DataSource object") | python | def dataSource(self, value):
""" sets the datasource object """
if isinstance(value, DataSource):
self._dataSource = value
else:
raise TypeError("value must be a DataSource object") | [
"def",
"dataSource",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"DataSource",
")",
":",
"self",
".",
"_dataSource",
"=",
"value",
"else",
":",
"raise",
"TypeError",
"(",
"\"value must be a DataSource object\"",
")"
] | sets the datasource object | [
"sets",
"the",
"datasource",
"object"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/layer.py#L1268-L1273 | train |
Esri/ArcREST | src/arcrest/ags/layer.py | DynamicDataLayer.fields | def fields(self, value):
"""sets the fields variable"""
if type(value) is list:
self._fields = value
else:
raise TypeError("Input must be a list") | python | def fields(self, value):
"""sets the fields variable"""
if type(value) is list:
self._fields = value
else:
raise TypeError("Input must be a list") | [
"def",
"fields",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"is",
"list",
":",
"self",
".",
"_fields",
"=",
"value",
"else",
":",
"raise",
"TypeError",
"(",
"\"Input must be a list\"",
")"
] | sets the fields variable | [
"sets",
"the",
"fields",
"variable"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/layer.py#L1281-L1286 | train |
Esri/ArcREST | src/arcrest/common/domain.py | CodedValueDomain.addCodedValue | def addCodedValue(self, name, code):
"""
adds a coded value to the domain
Inputs:
name - name of the domain
code - value
"""
i = {"name" : name, "code" : code}
if i not in self._codedValues:
self._codedValues.append(i) | python | def addCodedValue(self, name, code):
"""
adds a coded value to the domain
Inputs:
name - name of the domain
code - value
"""
i = {"name" : name, "code" : code}
if i not in self._codedValues:
self._codedValues.append(i) | [
"def",
"addCodedValue",
"(",
"self",
",",
"name",
",",
"code",
")",
":",
"i",
"=",
"{",
"\"name\"",
":",
"name",
",",
"\"code\"",
":",
"code",
"}",
"if",
"i",
"not",
"in",
"self",
".",
"_codedValues",
":",
"self",
".",
"_codedValues",
".",
"append",
"(",
"i",
")"
] | adds a coded value to the domain
Inputs:
name - name of the domain
code - value | [
"adds",
"a",
"coded",
"value",
"to",
"the",
"domain"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/domain.py#L59-L69 | train |
Esri/ArcREST | src/arcrest/common/domain.py | CodedValueDomain.removeCodedValue | def removeCodedValue(self, name):
"""removes a codedValue by name"""
for i in self._codedValues:
if i['name'] == name:
self._codedValues.remove(i)
return True
return False | python | def removeCodedValue(self, name):
"""removes a codedValue by name"""
for i in self._codedValues:
if i['name'] == name:
self._codedValues.remove(i)
return True
return False | [
"def",
"removeCodedValue",
"(",
"self",
",",
"name",
")",
":",
"for",
"i",
"in",
"self",
".",
"_codedValues",
":",
"if",
"i",
"[",
"'name'",
"]",
"==",
"name",
":",
"self",
".",
"_codedValues",
".",
"remove",
"(",
"i",
")",
"return",
"True",
"return",
"False"
] | removes a codedValue by name | [
"removes",
"a",
"codedValue",
"by",
"name"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/domain.py#L71-L77 | train |
Esri/ArcREST | src/arcrest/common/domain.py | RangeDomain.value | def value(self):
"""gets the value as a dictionary"""
return {
"type" : self._type,
"name" : self._name,
"range" : [self._rangeMin, self._rangeMax]
} | python | def value(self):
"""gets the value as a dictionary"""
return {
"type" : self._type,
"name" : self._name,
"range" : [self._rangeMin, self._rangeMax]
} | [
"def",
"value",
"(",
"self",
")",
":",
"return",
"{",
"\"type\"",
":",
"self",
".",
"_type",
",",
"\"name\"",
":",
"self",
".",
"_name",
",",
"\"range\"",
":",
"[",
"self",
".",
"_rangeMin",
",",
"self",
".",
"_rangeMax",
"]",
"}"
] | gets the value as a dictionary | [
"gets",
"the",
"value",
"as",
"a",
"dictionary"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/domain.py#L126-L132 | train |
Esri/ArcREST | src/arcrest/ags/_imageservice.py | ImageService.exportImage | def exportImage(self,
bbox,
imageSR,
bboxSR,
size=[400,400],
time=None,
format="jpgpng",
pixelType="UNKNOWN",
noData=None,
noDataInterpretation="esriNoDataMatchAny",
interpolation=None,
compression=None,
compressionQuality=75,
bandIds=None,
moasiacRule=None,
renderingRule="",
f="json",
saveFolder=None,
saveFile=None
):
"""
The exportImage operation is performed on an image service resource
The result of this operation is an image resource. This resource
provides information about the exported image, such as its URL,
extent, width, and height.
In addition to the usual response formats of HTML and JSON, you can
also request the image format while performing this operation. When
you perform an export with the image format , the server responds
by directly streaming the image bytes to the client. With this
approach, you don't get any information associated with the
exported image other than the image itself.
Inputs:
bbox - The extent (bounding box) of the exported image. Unless
the bboxSR parameter has been specified, the bbox is
assumed to be in the spatial reference of the image
service.
imageSR - The spatial reference of the exported image.
bboxSR - The spatial reference of the bbox.
size - The size (width * height) of the exported image in
pixels. If size is not specified, an image with a default
size of 400 * 400 will be exported.
time - The time instant or the time extent of the exported image.
format - The format of the exported image. The default format is
jpgpng.
Values: jpgpng | png | png8 | png24 | jpg | bmp | gif |
tiff | png32
pixelType - The pixel type, also known as data type, pertains to
the type of values stored in the raster, such as
signed integer, unsigned integer, or floating point.
Integers are whole numbers, whereas floating points
have decimals.
noDate - The pixel value representing no information.
noDataInterpretation - Interpretation of the noData setting. The
default is esriNoDataMatchAny when noData is
a number, and esriNoDataMatchAll when noData
is a comma-delimited string:
esriNoDataMatchAny | esriNoDataMatchAll.
interpolation - The resampling process of extrapolating the
pixel values while transforming the raster
dataset when it undergoes warping or when it
changes coordinate space.
compression - Controls how to compress the image when exporting
to TIFF format: None, JPEG, LZ77. It does not
control compression on other formats.
compressionQuality - Controls how much loss the image will be
subjected to by the compression algorithm.
Valid value ranges of compression quality
are from 0 to 100.
bandIds - If there are multiple bands, you can specify a single
band to export, or you can change the band combination
(red, green, blue) by specifying the band number. Band
number is 0 based.
mosaicRule - Specifies the mosaic rule when defining how
individual images should be mosaicked. When a mosaic
rule is not specified, the default mosaic rule of
the image service will be used (as advertised in
the root resource: defaultMosaicMethod,
mosaicOperator, sortField, sortValue).
renderingRule - Specifies the rendering rule for how the
requested image should be rendered.
f - The response format. default is json
Values: json | image | kmz
"""
params = {
"bbox" : bbox,
"imageSR": imageSR,
"bboxSR": bboxSR,
"size" : "%s %s" % (size[0], size[1]),
"pixelType" : pixelType,
"compressionQuality" : compressionQuality,
}
url = self._url + "/exportImage"
__allowedFormat = ["jpgpng", "png",
"png8", "png24",
"jpg", "bmp",
"gif", "tiff",
"png32"]
__allowedPixelTypes = [
"C128", "C64", "F32",
"F64", "S16", "S32",
"S8", "U1", "U16",
"U2", "U32", "U4",
"U8", "UNKNOWN"
]
__allowednoDataInt = [
"esriNoDataMatchAny",
"esriNoDataMatchAll"
]
__allowedInterpolation = [
"RSP_BilinearInterpolation",
"RSP_CubicConvolution",
"RSP_Majority",
"RSP_NearestNeighbor"
]
__allowedCompression = [
"JPEG", "LZ77"
]
if isinstance(moasiacRule,MosaicRuleObject):
params["moasiacRule"] = moasiacRule.value
if format in __allowedFormat:
params['format'] = format
if isinstance(time, datetime.datetime):
params['time'] = local_time_to_online(time)
if interpolation is not None and \
interpolation in __allowedInterpolation and \
isinstance(interpolation, str):
params['interpolation'] = interpolation
if pixelType is not None and \
pixelType in __allowedPixelTypes:
params['pixelType'] = pixelType
if noDataInterpretation in __allowedInterpolation:
params['noDataInterpretation'] = noDataInterpretation
if noData is not None:
params['noData'] = noData
if compression is not None and \
compression in __allowedCompression:
params['compression'] = compression
if bandIds is not None and \
isinstance(bandIds, list):
params['bandIds'] = ",".join(bandIds)
if renderingRule is not None:
params['renderingRule'] = renderingRule
params["f" ] = f
if f == "json":
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
elif f == "image":
result = self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
out_folder=saveFolder,
file_name=saveFile)
return result
elif f == "kmz":
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
out_folder=saveFolder,
file_name=saveFile) | python | def exportImage(self,
bbox,
imageSR,
bboxSR,
size=[400,400],
time=None,
format="jpgpng",
pixelType="UNKNOWN",
noData=None,
noDataInterpretation="esriNoDataMatchAny",
interpolation=None,
compression=None,
compressionQuality=75,
bandIds=None,
moasiacRule=None,
renderingRule="",
f="json",
saveFolder=None,
saveFile=None
):
"""
The exportImage operation is performed on an image service resource
The result of this operation is an image resource. This resource
provides information about the exported image, such as its URL,
extent, width, and height.
In addition to the usual response formats of HTML and JSON, you can
also request the image format while performing this operation. When
you perform an export with the image format , the server responds
by directly streaming the image bytes to the client. With this
approach, you don't get any information associated with the
exported image other than the image itself.
Inputs:
bbox - The extent (bounding box) of the exported image. Unless
the bboxSR parameter has been specified, the bbox is
assumed to be in the spatial reference of the image
service.
imageSR - The spatial reference of the exported image.
bboxSR - The spatial reference of the bbox.
size - The size (width * height) of the exported image in
pixels. If size is not specified, an image with a default
size of 400 * 400 will be exported.
time - The time instant or the time extent of the exported image.
format - The format of the exported image. The default format is
jpgpng.
Values: jpgpng | png | png8 | png24 | jpg | bmp | gif |
tiff | png32
pixelType - The pixel type, also known as data type, pertains to
the type of values stored in the raster, such as
signed integer, unsigned integer, or floating point.
Integers are whole numbers, whereas floating points
have decimals.
noDate - The pixel value representing no information.
noDataInterpretation - Interpretation of the noData setting. The
default is esriNoDataMatchAny when noData is
a number, and esriNoDataMatchAll when noData
is a comma-delimited string:
esriNoDataMatchAny | esriNoDataMatchAll.
interpolation - The resampling process of extrapolating the
pixel values while transforming the raster
dataset when it undergoes warping or when it
changes coordinate space.
compression - Controls how to compress the image when exporting
to TIFF format: None, JPEG, LZ77. It does not
control compression on other formats.
compressionQuality - Controls how much loss the image will be
subjected to by the compression algorithm.
Valid value ranges of compression quality
are from 0 to 100.
bandIds - If there are multiple bands, you can specify a single
band to export, or you can change the band combination
(red, green, blue) by specifying the band number. Band
number is 0 based.
mosaicRule - Specifies the mosaic rule when defining how
individual images should be mosaicked. When a mosaic
rule is not specified, the default mosaic rule of
the image service will be used (as advertised in
the root resource: defaultMosaicMethod,
mosaicOperator, sortField, sortValue).
renderingRule - Specifies the rendering rule for how the
requested image should be rendered.
f - The response format. default is json
Values: json | image | kmz
"""
params = {
"bbox" : bbox,
"imageSR": imageSR,
"bboxSR": bboxSR,
"size" : "%s %s" % (size[0], size[1]),
"pixelType" : pixelType,
"compressionQuality" : compressionQuality,
}
url = self._url + "/exportImage"
__allowedFormat = ["jpgpng", "png",
"png8", "png24",
"jpg", "bmp",
"gif", "tiff",
"png32"]
__allowedPixelTypes = [
"C128", "C64", "F32",
"F64", "S16", "S32",
"S8", "U1", "U16",
"U2", "U32", "U4",
"U8", "UNKNOWN"
]
__allowednoDataInt = [
"esriNoDataMatchAny",
"esriNoDataMatchAll"
]
__allowedInterpolation = [
"RSP_BilinearInterpolation",
"RSP_CubicConvolution",
"RSP_Majority",
"RSP_NearestNeighbor"
]
__allowedCompression = [
"JPEG", "LZ77"
]
if isinstance(moasiacRule,MosaicRuleObject):
params["moasiacRule"] = moasiacRule.value
if format in __allowedFormat:
params['format'] = format
if isinstance(time, datetime.datetime):
params['time'] = local_time_to_online(time)
if interpolation is not None and \
interpolation in __allowedInterpolation and \
isinstance(interpolation, str):
params['interpolation'] = interpolation
if pixelType is not None and \
pixelType in __allowedPixelTypes:
params['pixelType'] = pixelType
if noDataInterpretation in __allowedInterpolation:
params['noDataInterpretation'] = noDataInterpretation
if noData is not None:
params['noData'] = noData
if compression is not None and \
compression in __allowedCompression:
params['compression'] = compression
if bandIds is not None and \
isinstance(bandIds, list):
params['bandIds'] = ",".join(bandIds)
if renderingRule is not None:
params['renderingRule'] = renderingRule
params["f" ] = f
if f == "json":
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
elif f == "image":
result = self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
out_folder=saveFolder,
file_name=saveFile)
return result
elif f == "kmz":
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
out_folder=saveFolder,
file_name=saveFile) | [
"def",
"exportImage",
"(",
"self",
",",
"bbox",
",",
"imageSR",
",",
"bboxSR",
",",
"size",
"=",
"[",
"400",
",",
"400",
"]",
",",
"time",
"=",
"None",
",",
"format",
"=",
"\"jpgpng\"",
",",
"pixelType",
"=",
"\"UNKNOWN\"",
",",
"noData",
"=",
"None",
",",
"noDataInterpretation",
"=",
"\"esriNoDataMatchAny\"",
",",
"interpolation",
"=",
"None",
",",
"compression",
"=",
"None",
",",
"compressionQuality",
"=",
"75",
",",
"bandIds",
"=",
"None",
",",
"moasiacRule",
"=",
"None",
",",
"renderingRule",
"=",
"\"\"",
",",
"f",
"=",
"\"json\"",
",",
"saveFolder",
"=",
"None",
",",
"saveFile",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"bbox\"",
":",
"bbox",
",",
"\"imageSR\"",
":",
"imageSR",
",",
"\"bboxSR\"",
":",
"bboxSR",
",",
"\"size\"",
":",
"\"%s %s\"",
"%",
"(",
"size",
"[",
"0",
"]",
",",
"size",
"[",
"1",
"]",
")",
",",
"\"pixelType\"",
":",
"pixelType",
",",
"\"compressionQuality\"",
":",
"compressionQuality",
",",
"}",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/exportImage\"",
"__allowedFormat",
"=",
"[",
"\"jpgpng\"",
",",
"\"png\"",
",",
"\"png8\"",
",",
"\"png24\"",
",",
"\"jpg\"",
",",
"\"bmp\"",
",",
"\"gif\"",
",",
"\"tiff\"",
",",
"\"png32\"",
"]",
"__allowedPixelTypes",
"=",
"[",
"\"C128\"",
",",
"\"C64\"",
",",
"\"F32\"",
",",
"\"F64\"",
",",
"\"S16\"",
",",
"\"S32\"",
",",
"\"S8\"",
",",
"\"U1\"",
",",
"\"U16\"",
",",
"\"U2\"",
",",
"\"U32\"",
",",
"\"U4\"",
",",
"\"U8\"",
",",
"\"UNKNOWN\"",
"]",
"__allowednoDataInt",
"=",
"[",
"\"esriNoDataMatchAny\"",
",",
"\"esriNoDataMatchAll\"",
"]",
"__allowedInterpolation",
"=",
"[",
"\"RSP_BilinearInterpolation\"",
",",
"\"RSP_CubicConvolution\"",
",",
"\"RSP_Majority\"",
",",
"\"RSP_NearestNeighbor\"",
"]",
"__allowedCompression",
"=",
"[",
"\"JPEG\"",
",",
"\"LZ77\"",
"]",
"if",
"isinstance",
"(",
"moasiacRule",
",",
"MosaicRuleObject",
")",
":",
"params",
"[",
"\"moasiacRule\"",
"]",
"=",
"moasiacRule",
".",
"value",
"if",
"format",
"in",
"__allowedFormat",
":",
"params",
"[",
"'format'",
"]",
"=",
"format",
"if",
"isinstance",
"(",
"time",
",",
"datetime",
".",
"datetime",
")",
":",
"params",
"[",
"'time'",
"]",
"=",
"local_time_to_online",
"(",
"time",
")",
"if",
"interpolation",
"is",
"not",
"None",
"and",
"interpolation",
"in",
"__allowedInterpolation",
"and",
"isinstance",
"(",
"interpolation",
",",
"str",
")",
":",
"params",
"[",
"'interpolation'",
"]",
"=",
"interpolation",
"if",
"pixelType",
"is",
"not",
"None",
"and",
"pixelType",
"in",
"__allowedPixelTypes",
":",
"params",
"[",
"'pixelType'",
"]",
"=",
"pixelType",
"if",
"noDataInterpretation",
"in",
"__allowedInterpolation",
":",
"params",
"[",
"'noDataInterpretation'",
"]",
"=",
"noDataInterpretation",
"if",
"noData",
"is",
"not",
"None",
":",
"params",
"[",
"'noData'",
"]",
"=",
"noData",
"if",
"compression",
"is",
"not",
"None",
"and",
"compression",
"in",
"__allowedCompression",
":",
"params",
"[",
"'compression'",
"]",
"=",
"compression",
"if",
"bandIds",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"bandIds",
",",
"list",
")",
":",
"params",
"[",
"'bandIds'",
"]",
"=",
"\",\"",
".",
"join",
"(",
"bandIds",
")",
"if",
"renderingRule",
"is",
"not",
"None",
":",
"params",
"[",
"'renderingRule'",
"]",
"=",
"renderingRule",
"params",
"[",
"\"f\"",
"]",
"=",
"f",
"if",
"f",
"==",
"\"json\"",
":",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")",
"elif",
"f",
"==",
"\"image\"",
":",
"result",
"=",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"out_folder",
"=",
"saveFolder",
",",
"file_name",
"=",
"saveFile",
")",
"return",
"result",
"elif",
"f",
"==",
"\"kmz\"",
":",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"out_folder",
"=",
"saveFolder",
",",
"file_name",
"=",
"saveFile",
")"
] | The exportImage operation is performed on an image service resource
The result of this operation is an image resource. This resource
provides information about the exported image, such as its URL,
extent, width, and height.
In addition to the usual response formats of HTML and JSON, you can
also request the image format while performing this operation. When
you perform an export with the image format , the server responds
by directly streaming the image bytes to the client. With this
approach, you don't get any information associated with the
exported image other than the image itself.
Inputs:
bbox - The extent (bounding box) of the exported image. Unless
the bboxSR parameter has been specified, the bbox is
assumed to be in the spatial reference of the image
service.
imageSR - The spatial reference of the exported image.
bboxSR - The spatial reference of the bbox.
size - The size (width * height) of the exported image in
pixels. If size is not specified, an image with a default
size of 400 * 400 will be exported.
time - The time instant or the time extent of the exported image.
format - The format of the exported image. The default format is
jpgpng.
Values: jpgpng | png | png8 | png24 | jpg | bmp | gif |
tiff | png32
pixelType - The pixel type, also known as data type, pertains to
the type of values stored in the raster, such as
signed integer, unsigned integer, or floating point.
Integers are whole numbers, whereas floating points
have decimals.
noDate - The pixel value representing no information.
noDataInterpretation - Interpretation of the noData setting. The
default is esriNoDataMatchAny when noData is
a number, and esriNoDataMatchAll when noData
is a comma-delimited string:
esriNoDataMatchAny | esriNoDataMatchAll.
interpolation - The resampling process of extrapolating the
pixel values while transforming the raster
dataset when it undergoes warping or when it
changes coordinate space.
compression - Controls how to compress the image when exporting
to TIFF format: None, JPEG, LZ77. It does not
control compression on other formats.
compressionQuality - Controls how much loss the image will be
subjected to by the compression algorithm.
Valid value ranges of compression quality
are from 0 to 100.
bandIds - If there are multiple bands, you can specify a single
band to export, or you can change the band combination
(red, green, blue) by specifying the band number. Band
number is 0 based.
mosaicRule - Specifies the mosaic rule when defining how
individual images should be mosaicked. When a mosaic
rule is not specified, the default mosaic rule of
the image service will be used (as advertised in
the root resource: defaultMosaicMethod,
mosaicOperator, sortField, sortValue).
renderingRule - Specifies the rendering rule for how the
requested image should be rendered.
f - The response format. default is json
Values: json | image | kmz | [
"The",
"exportImage",
"operation",
"is",
"performed",
"on",
"an",
"image",
"service",
"resource",
"The",
"result",
"of",
"this",
"operation",
"is",
"an",
"image",
"resource",
".",
"This",
"resource",
"provides",
"information",
"about",
"the",
"exported",
"image",
"such",
"as",
"its",
"URL",
"extent",
"width",
"and",
"height",
".",
"In",
"addition",
"to",
"the",
"usual",
"response",
"formats",
"of",
"HTML",
"and",
"JSON",
"you",
"can",
"also",
"request",
"the",
"image",
"format",
"while",
"performing",
"this",
"operation",
".",
"When",
"you",
"perform",
"an",
"export",
"with",
"the",
"image",
"format",
"the",
"server",
"responds",
"by",
"directly",
"streaming",
"the",
"image",
"bytes",
"to",
"the",
"client",
".",
"With",
"this",
"approach",
"you",
"don",
"t",
"get",
"any",
"information",
"associated",
"with",
"the",
"exported",
"image",
"other",
"than",
"the",
"image",
"itself",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_imageservice.py#L435-L602 | train |
Esri/ArcREST | src/arcrest/ags/_imageservice.py | ImageService.measure | def measure(self,fromGeometry,toGeometry,measureOperation,
geometryType="esriGeometryPoint",pixelSize=None,mosaicRule=None,
linearUnit=None,angularUnit=None,areaUnit=None):
"""
The measure operation is performed on an image service resource. It
lets a user measure distance, direction, area, perimeter, and height
from an image service. The result of this operation includes the name
of the raster dataset being used, sensor name, and measured values.
The measure operation can be supported by image services from raster
datasets and mosaic datasets. Spatial reference is required to perform
basic measurement (distance, area, and so on). Sensor metadata (geodata
transformation) needs to be present in the data source used by an image
service to enable height measurement (for example, imagery with RPCs).
The mosaic dataset or service needs to include DEM to perform 3D measure.
Users can provide arguments to the measure operation as query parameters.
Inputs:
fromGeometry - A geometry that defines the "from" location of the
measurement. The structure of the geometry is the same as the structure
of the JSON geometry objects returned by the ArcGIS REST API. In addition
to the JSON structures, for points, you can specify the geometry with a
simple comma-separated syntax.
By default, the geometry is assumed to be in the spatial reference of
the image service. You can specify a different spatial reference by
using the JSON structure syntax for geometries.
toGeometry - A geometry that defines the "to" location of the measurement.
The type of geometry must be the same as fromGeometry. The structure of
the geometry is the same as the structure of the JSON geometry objects
returned by the ArcGIS REST API. In addition to the JSON structures, for
points, you can specify the geometry with a simple comma-separated syntax.
By default, the geometry is assumed to be in the spatial reference of
the image service. You can specify a different spatial reference by
using the JSON structure syntax for geometries.
geometryType - The type of geometry specified by the fromGeometry and
toGeometry parameters. The geometry type can be a point, polygon, or
envelope. The default geometry type is point.
Values: esriGeometryPoint | esriGeometryPolygon | esriGeometryEnvelope
measureOperation - Specifies the type of measure being performed.
Values: esriMensurationPoint | esriMensurationDistanceAndAngle |
esriMensurationAreaAndPerimeter | esriMensurationHeightFromBaseAndTop |
esriMensurationHeightFromBaseAndTopShadow |
esriMensurationHeightFromTopAndTopShadow | esriMensurationCentroid |
esriMensurationPoint3D | esriMensurationDistanceAndAngle3D |
esriMensurationAreaAndPerimeter3D | esriMensurationCentroid3D
pixelSize - The pixel level (resolution) being measured. If pixel size
is not specified, pixelSize will default to the base resolution of the
image service. The raster at the specified pixel size in the mosaic
dataset will be used for measurement.
The structure of the pixelSize parameter is the same as the structure
of the point object returned by the ArcGIS REST API. In addition to the
JSON structure, you can specify the pixel size with a simple
comma-separated syntax.
mosaicRule - Specifies the mosaic rule when defining how individual
images should be mosaicked. When a mosaic rule is not specified, the
default mosaic rule of the image service will be used (as advertised
in the root resource: defaultMosaicMethod, mosaicOperator, sortField,
sortValue). The first visible image is used by measure.
linearUnit - The linear unit in which height, length, or perimeters
will be calculated. It can be any of the following esriUnits constant.
If the unit is not specified, the default is esriMeters. The list of
valid esriUnits constants include:
esriInches | esriFeet | esriYards | esriMiles | esriNauticalMiles |
esriMillimeters | esriCentimeters | esriDecimeters | esriMeters |
esriKilometers
angularUnit - The angular unit in which directions of line segments
will be calculated. It can be one of the following esriDirectionUnits
constants: esriDURadians | esriDUDecimalDegrees
If the unit is not specified, the default is esriDUDecimalDegrees.
areaUnit - The area unit in which areas of polygons will be calculated.
It can be any esriAreaUnits constant. If the unit is not specified, the
default is esriSquareMeters. The list of valid esriAreaUnits constants
include:
esriSquareInches | esriSquareFeet | esriSquareYards | esriAcres |
esriSquareMiles | esriSquareMillimeters | esriSquareCentimeters |
esriSquareDecimeters | esriSquareMeters | esriAres | esriHectares |
esriSquareKilometers
"""
url = self._url + "/measure"
params = {
"f" : "json",
"fromGeometry" : fromGeometry,
"toGeometry": toGeometry,
"geometryType": geometryType,
"measureOperation": measureOperation
}
if not pixelSize is None:
params["pixelSize"] = pixelSize
if not mosaicRule is None:
params["mosaicRule"] = mosaicRule
if not linearUnit is None:
params["linearUnit"] = linearUnit
if not angularUnit is None:
params["angularUnit"] = angularUnit
if not areaUnit is None:
params["areaUnit"] = areaUnit
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def measure(self,fromGeometry,toGeometry,measureOperation,
geometryType="esriGeometryPoint",pixelSize=None,mosaicRule=None,
linearUnit=None,angularUnit=None,areaUnit=None):
"""
The measure operation is performed on an image service resource. It
lets a user measure distance, direction, area, perimeter, and height
from an image service. The result of this operation includes the name
of the raster dataset being used, sensor name, and measured values.
The measure operation can be supported by image services from raster
datasets and mosaic datasets. Spatial reference is required to perform
basic measurement (distance, area, and so on). Sensor metadata (geodata
transformation) needs to be present in the data source used by an image
service to enable height measurement (for example, imagery with RPCs).
The mosaic dataset or service needs to include DEM to perform 3D measure.
Users can provide arguments to the measure operation as query parameters.
Inputs:
fromGeometry - A geometry that defines the "from" location of the
measurement. The structure of the geometry is the same as the structure
of the JSON geometry objects returned by the ArcGIS REST API. In addition
to the JSON structures, for points, you can specify the geometry with a
simple comma-separated syntax.
By default, the geometry is assumed to be in the spatial reference of
the image service. You can specify a different spatial reference by
using the JSON structure syntax for geometries.
toGeometry - A geometry that defines the "to" location of the measurement.
The type of geometry must be the same as fromGeometry. The structure of
the geometry is the same as the structure of the JSON geometry objects
returned by the ArcGIS REST API. In addition to the JSON structures, for
points, you can specify the geometry with a simple comma-separated syntax.
By default, the geometry is assumed to be in the spatial reference of
the image service. You can specify a different spatial reference by
using the JSON structure syntax for geometries.
geometryType - The type of geometry specified by the fromGeometry and
toGeometry parameters. The geometry type can be a point, polygon, or
envelope. The default geometry type is point.
Values: esriGeometryPoint | esriGeometryPolygon | esriGeometryEnvelope
measureOperation - Specifies the type of measure being performed.
Values: esriMensurationPoint | esriMensurationDistanceAndAngle |
esriMensurationAreaAndPerimeter | esriMensurationHeightFromBaseAndTop |
esriMensurationHeightFromBaseAndTopShadow |
esriMensurationHeightFromTopAndTopShadow | esriMensurationCentroid |
esriMensurationPoint3D | esriMensurationDistanceAndAngle3D |
esriMensurationAreaAndPerimeter3D | esriMensurationCentroid3D
pixelSize - The pixel level (resolution) being measured. If pixel size
is not specified, pixelSize will default to the base resolution of the
image service. The raster at the specified pixel size in the mosaic
dataset will be used for measurement.
The structure of the pixelSize parameter is the same as the structure
of the point object returned by the ArcGIS REST API. In addition to the
JSON structure, you can specify the pixel size with a simple
comma-separated syntax.
mosaicRule - Specifies the mosaic rule when defining how individual
images should be mosaicked. When a mosaic rule is not specified, the
default mosaic rule of the image service will be used (as advertised
in the root resource: defaultMosaicMethod, mosaicOperator, sortField,
sortValue). The first visible image is used by measure.
linearUnit - The linear unit in which height, length, or perimeters
will be calculated. It can be any of the following esriUnits constant.
If the unit is not specified, the default is esriMeters. The list of
valid esriUnits constants include:
esriInches | esriFeet | esriYards | esriMiles | esriNauticalMiles |
esriMillimeters | esriCentimeters | esriDecimeters | esriMeters |
esriKilometers
angularUnit - The angular unit in which directions of line segments
will be calculated. It can be one of the following esriDirectionUnits
constants: esriDURadians | esriDUDecimalDegrees
If the unit is not specified, the default is esriDUDecimalDegrees.
areaUnit - The area unit in which areas of polygons will be calculated.
It can be any esriAreaUnits constant. If the unit is not specified, the
default is esriSquareMeters. The list of valid esriAreaUnits constants
include:
esriSquareInches | esriSquareFeet | esriSquareYards | esriAcres |
esriSquareMiles | esriSquareMillimeters | esriSquareCentimeters |
esriSquareDecimeters | esriSquareMeters | esriAres | esriHectares |
esriSquareKilometers
"""
url = self._url + "/measure"
params = {
"f" : "json",
"fromGeometry" : fromGeometry,
"toGeometry": toGeometry,
"geometryType": geometryType,
"measureOperation": measureOperation
}
if not pixelSize is None:
params["pixelSize"] = pixelSize
if not mosaicRule is None:
params["mosaicRule"] = mosaicRule
if not linearUnit is None:
params["linearUnit"] = linearUnit
if not angularUnit is None:
params["angularUnit"] = angularUnit
if not areaUnit is None:
params["areaUnit"] = areaUnit
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"measure",
"(",
"self",
",",
"fromGeometry",
",",
"toGeometry",
",",
"measureOperation",
",",
"geometryType",
"=",
"\"esriGeometryPoint\"",
",",
"pixelSize",
"=",
"None",
",",
"mosaicRule",
"=",
"None",
",",
"linearUnit",
"=",
"None",
",",
"angularUnit",
"=",
"None",
",",
"areaUnit",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/measure\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"fromGeometry\"",
":",
"fromGeometry",
",",
"\"toGeometry\"",
":",
"toGeometry",
",",
"\"geometryType\"",
":",
"geometryType",
",",
"\"measureOperation\"",
":",
"measureOperation",
"}",
"if",
"not",
"pixelSize",
"is",
"None",
":",
"params",
"[",
"\"pixelSize\"",
"]",
"=",
"pixelSize",
"if",
"not",
"mosaicRule",
"is",
"None",
":",
"params",
"[",
"\"mosaicRule\"",
"]",
"=",
"mosaicRule",
"if",
"not",
"linearUnit",
"is",
"None",
":",
"params",
"[",
"\"linearUnit\"",
"]",
"=",
"linearUnit",
"if",
"not",
"angularUnit",
"is",
"None",
":",
"params",
"[",
"\"angularUnit\"",
"]",
"=",
"angularUnit",
"if",
"not",
"areaUnit",
"is",
"None",
":",
"params",
"[",
"\"areaUnit\"",
"]",
"=",
"areaUnit",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | The measure operation is performed on an image service resource. It
lets a user measure distance, direction, area, perimeter, and height
from an image service. The result of this operation includes the name
of the raster dataset being used, sensor name, and measured values.
The measure operation can be supported by image services from raster
datasets and mosaic datasets. Spatial reference is required to perform
basic measurement (distance, area, and so on). Sensor metadata (geodata
transformation) needs to be present in the data source used by an image
service to enable height measurement (for example, imagery with RPCs).
The mosaic dataset or service needs to include DEM to perform 3D measure.
Users can provide arguments to the measure operation as query parameters.
Inputs:
fromGeometry - A geometry that defines the "from" location of the
measurement. The structure of the geometry is the same as the structure
of the JSON geometry objects returned by the ArcGIS REST API. In addition
to the JSON structures, for points, you can specify the geometry with a
simple comma-separated syntax.
By default, the geometry is assumed to be in the spatial reference of
the image service. You can specify a different spatial reference by
using the JSON structure syntax for geometries.
toGeometry - A geometry that defines the "to" location of the measurement.
The type of geometry must be the same as fromGeometry. The structure of
the geometry is the same as the structure of the JSON geometry objects
returned by the ArcGIS REST API. In addition to the JSON structures, for
points, you can specify the geometry with a simple comma-separated syntax.
By default, the geometry is assumed to be in the spatial reference of
the image service. You can specify a different spatial reference by
using the JSON structure syntax for geometries.
geometryType - The type of geometry specified by the fromGeometry and
toGeometry parameters. The geometry type can be a point, polygon, or
envelope. The default geometry type is point.
Values: esriGeometryPoint | esriGeometryPolygon | esriGeometryEnvelope
measureOperation - Specifies the type of measure being performed.
Values: esriMensurationPoint | esriMensurationDistanceAndAngle |
esriMensurationAreaAndPerimeter | esriMensurationHeightFromBaseAndTop |
esriMensurationHeightFromBaseAndTopShadow |
esriMensurationHeightFromTopAndTopShadow | esriMensurationCentroid |
esriMensurationPoint3D | esriMensurationDistanceAndAngle3D |
esriMensurationAreaAndPerimeter3D | esriMensurationCentroid3D
pixelSize - The pixel level (resolution) being measured. If pixel size
is not specified, pixelSize will default to the base resolution of the
image service. The raster at the specified pixel size in the mosaic
dataset will be used for measurement.
The structure of the pixelSize parameter is the same as the structure
of the point object returned by the ArcGIS REST API. In addition to the
JSON structure, you can specify the pixel size with a simple
comma-separated syntax.
mosaicRule - Specifies the mosaic rule when defining how individual
images should be mosaicked. When a mosaic rule is not specified, the
default mosaic rule of the image service will be used (as advertised
in the root resource: defaultMosaicMethod, mosaicOperator, sortField,
sortValue). The first visible image is used by measure.
linearUnit - The linear unit in which height, length, or perimeters
will be calculated. It can be any of the following esriUnits constant.
If the unit is not specified, the default is esriMeters. The list of
valid esriUnits constants include:
esriInches | esriFeet | esriYards | esriMiles | esriNauticalMiles |
esriMillimeters | esriCentimeters | esriDecimeters | esriMeters |
esriKilometers
angularUnit - The angular unit in which directions of line segments
will be calculated. It can be one of the following esriDirectionUnits
constants: esriDURadians | esriDUDecimalDegrees
If the unit is not specified, the default is esriDUDecimalDegrees.
areaUnit - The area unit in which areas of polygons will be calculated.
It can be any esriAreaUnits constant. If the unit is not specified, the
default is esriSquareMeters. The list of valid esriAreaUnits constants
include:
esriSquareInches | esriSquareFeet | esriSquareYards | esriAcres |
esriSquareMiles | esriSquareMillimeters | esriSquareCentimeters |
esriSquareDecimeters | esriSquareMeters | esriAres | esriHectares |
esriSquareKilometers | [
"The",
"measure",
"operation",
"is",
"performed",
"on",
"an",
"image",
"service",
"resource",
".",
"It",
"lets",
"a",
"user",
"measure",
"distance",
"direction",
"area",
"perimeter",
"and",
"height",
"from",
"an",
"image",
"service",
".",
"The",
"result",
"of",
"this",
"operation",
"includes",
"the",
"name",
"of",
"the",
"raster",
"dataset",
"being",
"used",
"sensor",
"name",
"and",
"measured",
"values",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_imageservice.py#L916-L1030 | train |
Esri/ArcREST | src/arcrest/ags/_imageservice.py | ImageService.computeStatisticsHistograms | def computeStatisticsHistograms(self,geometry,geometryType,mosaicRule=None,
renderingRule=None,pixelSize=None):
"""
The computeStatisticsHistograms operation is performed on an image service
resource. This operation is supported by any image service published with
mosaic datasets or a raster dataset. The result of this operation contains
both statistics and histograms computed from the given extent.
Inputs:
geometry - A geometry that defines the geometry within which the histogram
is computed. The geometry can be an envelope or a polygon. The structure of
the geometry is the same as the structure of the JSON geometry objects
returned by the ArcGIS REST API.
geometryType - The type of geometry specified by the geometry parameter.
The geometry type can be an envelope or polygon.
Values: esriGeometryEnvelope | esriGeometryPolygon
mosaicRule - Specifies the mosaic rule when defining how individual
images should be mosaicked. When a mosaic rule is not specified, the
default mosaic rule of the image service will be used (as advertised
in the root resource: defaultMosaicMethod, mosaicOperator, sortField,
sortValue).
renderingRule - Specifies the rendering rule for how the requested
image should be rendered.
pixelSize - The pixel level being used (or the resolution being looked at).
If pixel size is not specified, then pixelSize will default to the base
resolution of the dataset. The raster at the specified pixel size in the
mosaic dataset will be used for histogram calculation.
The structure of the pixelSize parameter is the same as the structure of
the point object returned by the ArcGIS REST API. In addition to the JSON
structure, you can specify the pixel size with a simple comma-separated syntax.
"""
url = self._url + "/computeStatisticsHistograms"
params = {
"f" : "json",
"geometry" : geometry,
"geometryType": geometryType
}
if not mosaicRule is None:
params["mosaicRule"] = mosaicRule
if not renderingRule is None:
params["renderingRule"] = renderingRule
if not pixelSize is None:
params["pixelSize"] = pixelSize
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def computeStatisticsHistograms(self,geometry,geometryType,mosaicRule=None,
renderingRule=None,pixelSize=None):
"""
The computeStatisticsHistograms operation is performed on an image service
resource. This operation is supported by any image service published with
mosaic datasets or a raster dataset. The result of this operation contains
both statistics and histograms computed from the given extent.
Inputs:
geometry - A geometry that defines the geometry within which the histogram
is computed. The geometry can be an envelope or a polygon. The structure of
the geometry is the same as the structure of the JSON geometry objects
returned by the ArcGIS REST API.
geometryType - The type of geometry specified by the geometry parameter.
The geometry type can be an envelope or polygon.
Values: esriGeometryEnvelope | esriGeometryPolygon
mosaicRule - Specifies the mosaic rule when defining how individual
images should be mosaicked. When a mosaic rule is not specified, the
default mosaic rule of the image service will be used (as advertised
in the root resource: defaultMosaicMethod, mosaicOperator, sortField,
sortValue).
renderingRule - Specifies the rendering rule for how the requested
image should be rendered.
pixelSize - The pixel level being used (or the resolution being looked at).
If pixel size is not specified, then pixelSize will default to the base
resolution of the dataset. The raster at the specified pixel size in the
mosaic dataset will be used for histogram calculation.
The structure of the pixelSize parameter is the same as the structure of
the point object returned by the ArcGIS REST API. In addition to the JSON
structure, you can specify the pixel size with a simple comma-separated syntax.
"""
url = self._url + "/computeStatisticsHistograms"
params = {
"f" : "json",
"geometry" : geometry,
"geometryType": geometryType
}
if not mosaicRule is None:
params["mosaicRule"] = mosaicRule
if not renderingRule is None:
params["renderingRule"] = renderingRule
if not pixelSize is None:
params["pixelSize"] = pixelSize
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"computeStatisticsHistograms",
"(",
"self",
",",
"geometry",
",",
"geometryType",
",",
"mosaicRule",
"=",
"None",
",",
"renderingRule",
"=",
"None",
",",
"pixelSize",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/computeStatisticsHistograms\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"geometry\"",
":",
"geometry",
",",
"\"geometryType\"",
":",
"geometryType",
"}",
"if",
"not",
"mosaicRule",
"is",
"None",
":",
"params",
"[",
"\"mosaicRule\"",
"]",
"=",
"mosaicRule",
"if",
"not",
"renderingRule",
"is",
"None",
":",
"params",
"[",
"\"renderingRule\"",
"]",
"=",
"renderingRule",
"if",
"not",
"pixelSize",
"is",
"None",
":",
"params",
"[",
"\"pixelSize\"",
"]",
"=",
"pixelSize",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | The computeStatisticsHistograms operation is performed on an image service
resource. This operation is supported by any image service published with
mosaic datasets or a raster dataset. The result of this operation contains
both statistics and histograms computed from the given extent.
Inputs:
geometry - A geometry that defines the geometry within which the histogram
is computed. The geometry can be an envelope or a polygon. The structure of
the geometry is the same as the structure of the JSON geometry objects
returned by the ArcGIS REST API.
geometryType - The type of geometry specified by the geometry parameter.
The geometry type can be an envelope or polygon.
Values: esriGeometryEnvelope | esriGeometryPolygon
mosaicRule - Specifies the mosaic rule when defining how individual
images should be mosaicked. When a mosaic rule is not specified, the
default mosaic rule of the image service will be used (as advertised
in the root resource: defaultMosaicMethod, mosaicOperator, sortField,
sortValue).
renderingRule - Specifies the rendering rule for how the requested
image should be rendered.
pixelSize - The pixel level being used (or the resolution being looked at).
If pixel size is not specified, then pixelSize will default to the base
resolution of the dataset. The raster at the specified pixel size in the
mosaic dataset will be used for histogram calculation.
The structure of the pixelSize parameter is the same as the structure of
the point object returned by the ArcGIS REST API. In addition to the JSON
structure, you can specify the pixel size with a simple comma-separated syntax. | [
"The",
"computeStatisticsHistograms",
"operation",
"is",
"performed",
"on",
"an",
"image",
"service",
"resource",
".",
"This",
"operation",
"is",
"supported",
"by",
"any",
"image",
"service",
"published",
"with",
"mosaic",
"datasets",
"or",
"a",
"raster",
"dataset",
".",
"The",
"result",
"of",
"this",
"operation",
"contains",
"both",
"statistics",
"and",
"histograms",
"computed",
"from",
"the",
"given",
"extent",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_imageservice.py#L1089-L1144 | train |
Esri/ArcREST | src/arcrest/agol/_uploads.py | Uploads.uploadByParts | def uploadByParts(self, registerID, filePath, commit=True):
"""
loads the data by small parts. If commit is set to true,
then parts will be merged together. If commit is false, the
function will return the registerID so a manual commit can occur.
If the user's file is over 10mbs, the uploadByParts should be used.
Inputs:
registerID - ID of the registered item
filePath - path of the file to upload
commit - default True, lets the function know if server will piece
the file back together on the server side.
Output:
dictionary or string
"""
url = self._url + "/%s/uploadPart" % registerID
params = {
"f" : "json"
}
with open(filePath, 'rb') as f:
mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
size = 1000000
steps = int(os.fstat(f.fileno()).st_size / size)
if os.fstat(f.fileno()).st_size % size > 0:
steps += 1
for i in range(steps):
files = {}
tempFile = os.path.join(os.environ['TEMP'], "split.part%s" % i)
if os.path.isfile(tempFile):
os.remove(tempFile)
with open(tempFile, 'wb') as writer:
writer.write(mm.read(size))
writer.flush()
writer.close()
del writer
files['file'] = tempFile
params['partNum'] = i + 1
res = self._post(url=url,
param_dict=params,
files=files,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
os.remove(tempFile)
del files
del mm
return self.commit(registerID) | python | def uploadByParts(self, registerID, filePath, commit=True):
"""
loads the data by small parts. If commit is set to true,
then parts will be merged together. If commit is false, the
function will return the registerID so a manual commit can occur.
If the user's file is over 10mbs, the uploadByParts should be used.
Inputs:
registerID - ID of the registered item
filePath - path of the file to upload
commit - default True, lets the function know if server will piece
the file back together on the server side.
Output:
dictionary or string
"""
url = self._url + "/%s/uploadPart" % registerID
params = {
"f" : "json"
}
with open(filePath, 'rb') as f:
mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
size = 1000000
steps = int(os.fstat(f.fileno()).st_size / size)
if os.fstat(f.fileno()).st_size % size > 0:
steps += 1
for i in range(steps):
files = {}
tempFile = os.path.join(os.environ['TEMP'], "split.part%s" % i)
if os.path.isfile(tempFile):
os.remove(tempFile)
with open(tempFile, 'wb') as writer:
writer.write(mm.read(size))
writer.flush()
writer.close()
del writer
files['file'] = tempFile
params['partNum'] = i + 1
res = self._post(url=url,
param_dict=params,
files=files,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
os.remove(tempFile)
del files
del mm
return self.commit(registerID) | [
"def",
"uploadByParts",
"(",
"self",
",",
"registerID",
",",
"filePath",
",",
"commit",
"=",
"True",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/%s/uploadPart\"",
"%",
"registerID",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"with",
"open",
"(",
"filePath",
",",
"'rb'",
")",
"as",
"f",
":",
"mm",
"=",
"mmap",
".",
"mmap",
"(",
"f",
".",
"fileno",
"(",
")",
",",
"0",
",",
"access",
"=",
"mmap",
".",
"ACCESS_READ",
")",
"size",
"=",
"1000000",
"steps",
"=",
"int",
"(",
"os",
".",
"fstat",
"(",
"f",
".",
"fileno",
"(",
")",
")",
".",
"st_size",
"/",
"size",
")",
"if",
"os",
".",
"fstat",
"(",
"f",
".",
"fileno",
"(",
")",
")",
".",
"st_size",
"%",
"size",
">",
"0",
":",
"steps",
"+=",
"1",
"for",
"i",
"in",
"range",
"(",
"steps",
")",
":",
"files",
"=",
"{",
"}",
"tempFile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
"[",
"'TEMP'",
"]",
",",
"\"split.part%s\"",
"%",
"i",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"tempFile",
")",
":",
"os",
".",
"remove",
"(",
"tempFile",
")",
"with",
"open",
"(",
"tempFile",
",",
"'wb'",
")",
"as",
"writer",
":",
"writer",
".",
"write",
"(",
"mm",
".",
"read",
"(",
"size",
")",
")",
"writer",
".",
"flush",
"(",
")",
"writer",
".",
"close",
"(",
")",
"del",
"writer",
"files",
"[",
"'file'",
"]",
"=",
"tempFile",
"params",
"[",
"'partNum'",
"]",
"=",
"i",
"+",
"1",
"res",
"=",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"files",
"=",
"files",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"os",
".",
"remove",
"(",
"tempFile",
")",
"del",
"files",
"del",
"mm",
"return",
"self",
".",
"commit",
"(",
"registerID",
")"
] | loads the data by small parts. If commit is set to true,
then parts will be merged together. If commit is false, the
function will return the registerID so a manual commit can occur.
If the user's file is over 10mbs, the uploadByParts should be used.
Inputs:
registerID - ID of the registered item
filePath - path of the file to upload
commit - default True, lets the function know if server will piece
the file back together on the server side.
Output:
dictionary or string | [
"loads",
"the",
"data",
"by",
"small",
"parts",
".",
"If",
"commit",
"is",
"set",
"to",
"true",
"then",
"parts",
"will",
"be",
"merged",
"together",
".",
"If",
"commit",
"is",
"false",
"the",
"function",
"will",
"return",
"the",
"registerID",
"so",
"a",
"manual",
"commit",
"can",
"occur",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/_uploads.py#L89-L136 | train |
Esri/ArcREST | src/arcrest/agol/services.py | FeatureService.uploads | def uploads(self):
"""returns the class to perform the upload function. it will
only return the uploads class if syncEnabled is True.
"""
if self.syncEnabled == True:
return Uploads(url=self._url + "/uploads",
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
return None | python | def uploads(self):
"""returns the class to perform the upload function. it will
only return the uploads class if syncEnabled is True.
"""
if self.syncEnabled == True:
return Uploads(url=self._url + "/uploads",
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
return None | [
"def",
"uploads",
"(",
"self",
")",
":",
"if",
"self",
".",
"syncEnabled",
"==",
"True",
":",
"return",
"Uploads",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/uploads\"",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"return",
"None"
] | returns the class to perform the upload function. it will
only return the uploads class if syncEnabled is True. | [
"returns",
"the",
"class",
"to",
"perform",
"the",
"upload",
"function",
".",
"it",
"will",
"only",
"return",
"the",
"uploads",
"class",
"if",
"syncEnabled",
"is",
"True",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L287-L296 | train |
Esri/ArcREST | src/arcrest/agol/services.py | FeatureService.administration | def administration(self):
"""returns the hostservice object to manage the back-end functions"""
url = self._url
res = search("/rest/", url).span()
addText = "admin/"
part1 = url[:res[1]]
part2 = url[res[1]:]
adminURL = "%s%s%s" % (part1, addText, part2)
res = AdminFeatureService(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False)
return res | python | def administration(self):
"""returns the hostservice object to manage the back-end functions"""
url = self._url
res = search("/rest/", url).span()
addText = "admin/"
part1 = url[:res[1]]
part2 = url[res[1]:]
adminURL = "%s%s%s" % (part1, addText, part2)
res = AdminFeatureService(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=False)
return res | [
"def",
"administration",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_url",
"res",
"=",
"search",
"(",
"\"/rest/\"",
",",
"url",
")",
".",
"span",
"(",
")",
"addText",
"=",
"\"admin/\"",
"part1",
"=",
"url",
"[",
":",
"res",
"[",
"1",
"]",
"]",
"part2",
"=",
"url",
"[",
"res",
"[",
"1",
"]",
":",
"]",
"adminURL",
"=",
"\"%s%s%s\"",
"%",
"(",
"part1",
",",
"addText",
",",
"part2",
")",
"res",
"=",
"AdminFeatureService",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"False",
")",
"return",
"res"
] | returns the hostservice object to manage the back-end functions | [
"returns",
"the",
"hostservice",
"object",
"to",
"manage",
"the",
"back",
"-",
"end",
"functions"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L405-L419 | train |
Esri/ArcREST | src/arcrest/agol/services.py | FeatureService.replicas | def replicas(self):
""" returns all the replicas for a feature service """
params = {
"f" : "json",
}
url = self._url + "/replicas"
return self._get(url, params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def replicas(self):
""" returns all the replicas for a feature service """
params = {
"f" : "json",
}
url = self._url + "/replicas"
return self._get(url, params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"replicas",
"(",
"self",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"}",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/replicas\"",
"return",
"self",
".",
"_get",
"(",
"url",
",",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | returns all the replicas for a feature service | [
"returns",
"all",
"the",
"replicas",
"for",
"a",
"feature",
"service"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L585-L595 | train |
Esri/ArcREST | src/arcrest/agol/services.py | FeatureService.createReplica | def createReplica(self,
replicaName,
layers,
layerQueries=None,
geometryFilter=None,
replicaSR=None,
transportType="esriTransportTypeUrl",
returnAttachments=False,
returnAttachmentsDatabyURL=False,
async=False,
attachmentsSyncDirection="none",
syncModel="none",
dataFormat="json",
replicaOptions=None,
wait=False,
out_path=None):
"""
The createReplica operation is performed on a feature service
resource. This operation creates the replica between the feature
service and a client based on a client-supplied replica definition.
It requires the Sync capability. See Sync overview for more
information on sync. The response for createReplica includes
replicaID, server generation number, and data similar to the
response from the feature service query operation.
The createReplica operation returns a response of type
esriReplicaResponseTypeData, as the response has data for the
layers in the replica. If the operation is called to register
existing data by using replicaOptions, the response type will be
esriReplicaResponseTypeInfo, and the response will not contain data
for the layers in the replica.
Inputs:
replicaName - name of the replica
layers - layers to export
layerQueries - In addition to the layers and geometry parameters, the layerQueries
parameter can be used to further define what is replicated. This
parameter allows you to set properties on a per layer or per table
basis. Only the properties for the layers and tables that you want
changed from the default are required.
Example:
layerQueries = {"0":{"queryOption": "useFilter", "useGeometry": true,
"where": "requires_inspection = Yes"}}
geometryFilter - Geospatial filter applied to the replica to
parse down data output.
returnAttachments - If true, attachments are added to the replica and returned in the
response. Otherwise, attachments are not included.
returnAttachmentDatabyURL - If true, a reference to a URL will be provided for each
attachment returned from createReplica. Otherwise,
attachments are embedded in the response.
replicaSR - the spatial reference of the replica geometry.
transportType - The transportType represents the response format. If the
transportType is esriTransportTypeUrl, the JSON response is contained in a file,
and the URL link to the file is returned. Otherwise, the JSON object is returned
directly. The default is esriTransportTypeUrl.
If async is true, the results will always be returned as if transportType is
esriTransportTypeUrl. If dataFormat is sqlite, the transportFormat will always be
esriTransportTypeUrl regardless of how the parameter is set.
Values: esriTransportTypeUrl | esriTransportTypeEmbedded
returnAttachments - If true, attachments are added to the replica and returned in
the response. Otherwise, attachments are not included. The default is false. This
parameter is only applicable if the feature service has attachments.
returnAttachmentsDatabyURL - If true, a reference to a URL will be provided for
each attachment returned from createReplica. Otherwise, attachments are embedded
in the response. The default is true. This parameter is only applicable if the
feature service has attachments and if returnAttachments is true.
attachmentsSyncDirection - Client can specify the attachmentsSyncDirection when
creating a replica. AttachmentsSyncDirection is currently a createReplica property
and cannot be overridden during sync.
Values: none, upload, bidirectional
async - If true, the request is processed as an asynchronous job, and a URL is
returned that a client can visit to check the status of the job. See the topic on
asynchronous usage for more information. The default is false.
syncModel - Client can specify the attachmentsSyncDirection when creating a replica.
AttachmentsSyncDirection is currently a createReplica property and cannot be
overridden during sync.
dataFormat - The format of the replica geodatabase returned in the response. The
default is json.
Values: filegdb, json, sqlite, shapefile
replicaOptions - This parameter instructs the createReplica operation to create a
new replica based on an existing replica definition (refReplicaId). It can be used
to specify parameters for registration of existing data for sync. The operation
will create a replica but will not return data. The responseType returned in the
createReplica response will be esriReplicaResponseTypeInfo.
wait - if async, wait to pause the process until the async operation is completed.
out_path - folder path to save the file
"""
if self.syncEnabled == False and "Extract" not in self.capabilities:
return None
url = self._url + "/createReplica"
dataformat = ["filegdb", "json", "sqlite", "shapefile"]
params = {"f" : "json",
"replicaName": replicaName,
"returnAttachments": returnAttachments,
"returnAttachmentsDatabyURL": returnAttachmentsDatabyURL,
"attachmentsSyncDirection" : attachmentsSyncDirection,
"async" : async,
"syncModel" : syncModel,
"layers" : layers
}
if dataFormat.lower() in dataformat:
params['dataFormat'] = dataFormat.lower()
else:
raise Exception("Invalid dataFormat")
if layerQueries is not None:
params['layerQueries'] = layerQueries
if geometryFilter is not None and \
isinstance(geometryFilter, GeometryFilter):
params.update(geometryFilter.filter)
if replicaSR is not None:
params['replicaSR'] = replicaSR
if replicaOptions is not None:
params['replicaOptions'] = replicaOptions
if transportType is not None:
params['transportType'] = transportType
if async:
if wait:
exportJob = self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
status = self.replicaStatus(url=exportJob['statusUrl'])
while status['status'].lower() != "completed":
status = self.replicaStatus(url=exportJob['statusUrl'])
if status['status'].lower() == "failed":
return status
res = status
else:
res = self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
else:
res = self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
if out_path is not None and \
os.path.isdir(out_path):
dlURL = None
if 'resultUrl' in res:
dlURL = res["resultUrl"]
elif 'responseUrl' in res:
dlURL = res["responseUrl"]
elif 'URL' in res:
dlURL = res["URL"]
if dlURL is not None:
return self._get(url=dlURL,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
out_folder=out_path)
else:
return res
elif res is not None:
return res
return None | python | def createReplica(self,
replicaName,
layers,
layerQueries=None,
geometryFilter=None,
replicaSR=None,
transportType="esriTransportTypeUrl",
returnAttachments=False,
returnAttachmentsDatabyURL=False,
async=False,
attachmentsSyncDirection="none",
syncModel="none",
dataFormat="json",
replicaOptions=None,
wait=False,
out_path=None):
"""
The createReplica operation is performed on a feature service
resource. This operation creates the replica between the feature
service and a client based on a client-supplied replica definition.
It requires the Sync capability. See Sync overview for more
information on sync. The response for createReplica includes
replicaID, server generation number, and data similar to the
response from the feature service query operation.
The createReplica operation returns a response of type
esriReplicaResponseTypeData, as the response has data for the
layers in the replica. If the operation is called to register
existing data by using replicaOptions, the response type will be
esriReplicaResponseTypeInfo, and the response will not contain data
for the layers in the replica.
Inputs:
replicaName - name of the replica
layers - layers to export
layerQueries - In addition to the layers and geometry parameters, the layerQueries
parameter can be used to further define what is replicated. This
parameter allows you to set properties on a per layer or per table
basis. Only the properties for the layers and tables that you want
changed from the default are required.
Example:
layerQueries = {"0":{"queryOption": "useFilter", "useGeometry": true,
"where": "requires_inspection = Yes"}}
geometryFilter - Geospatial filter applied to the replica to
parse down data output.
returnAttachments - If true, attachments are added to the replica and returned in the
response. Otherwise, attachments are not included.
returnAttachmentDatabyURL - If true, a reference to a URL will be provided for each
attachment returned from createReplica. Otherwise,
attachments are embedded in the response.
replicaSR - the spatial reference of the replica geometry.
transportType - The transportType represents the response format. If the
transportType is esriTransportTypeUrl, the JSON response is contained in a file,
and the URL link to the file is returned. Otherwise, the JSON object is returned
directly. The default is esriTransportTypeUrl.
If async is true, the results will always be returned as if transportType is
esriTransportTypeUrl. If dataFormat is sqlite, the transportFormat will always be
esriTransportTypeUrl regardless of how the parameter is set.
Values: esriTransportTypeUrl | esriTransportTypeEmbedded
returnAttachments - If true, attachments are added to the replica and returned in
the response. Otherwise, attachments are not included. The default is false. This
parameter is only applicable if the feature service has attachments.
returnAttachmentsDatabyURL - If true, a reference to a URL will be provided for
each attachment returned from createReplica. Otherwise, attachments are embedded
in the response. The default is true. This parameter is only applicable if the
feature service has attachments and if returnAttachments is true.
attachmentsSyncDirection - Client can specify the attachmentsSyncDirection when
creating a replica. AttachmentsSyncDirection is currently a createReplica property
and cannot be overridden during sync.
Values: none, upload, bidirectional
async - If true, the request is processed as an asynchronous job, and a URL is
returned that a client can visit to check the status of the job. See the topic on
asynchronous usage for more information. The default is false.
syncModel - Client can specify the attachmentsSyncDirection when creating a replica.
AttachmentsSyncDirection is currently a createReplica property and cannot be
overridden during sync.
dataFormat - The format of the replica geodatabase returned in the response. The
default is json.
Values: filegdb, json, sqlite, shapefile
replicaOptions - This parameter instructs the createReplica operation to create a
new replica based on an existing replica definition (refReplicaId). It can be used
to specify parameters for registration of existing data for sync. The operation
will create a replica but will not return data. The responseType returned in the
createReplica response will be esriReplicaResponseTypeInfo.
wait - if async, wait to pause the process until the async operation is completed.
out_path - folder path to save the file
"""
if self.syncEnabled == False and "Extract" not in self.capabilities:
return None
url = self._url + "/createReplica"
dataformat = ["filegdb", "json", "sqlite", "shapefile"]
params = {"f" : "json",
"replicaName": replicaName,
"returnAttachments": returnAttachments,
"returnAttachmentsDatabyURL": returnAttachmentsDatabyURL,
"attachmentsSyncDirection" : attachmentsSyncDirection,
"async" : async,
"syncModel" : syncModel,
"layers" : layers
}
if dataFormat.lower() in dataformat:
params['dataFormat'] = dataFormat.lower()
else:
raise Exception("Invalid dataFormat")
if layerQueries is not None:
params['layerQueries'] = layerQueries
if geometryFilter is not None and \
isinstance(geometryFilter, GeometryFilter):
params.update(geometryFilter.filter)
if replicaSR is not None:
params['replicaSR'] = replicaSR
if replicaOptions is not None:
params['replicaOptions'] = replicaOptions
if transportType is not None:
params['transportType'] = transportType
if async:
if wait:
exportJob = self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
status = self.replicaStatus(url=exportJob['statusUrl'])
while status['status'].lower() != "completed":
status = self.replicaStatus(url=exportJob['statusUrl'])
if status['status'].lower() == "failed":
return status
res = status
else:
res = self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
else:
res = self._post(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
if out_path is not None and \
os.path.isdir(out_path):
dlURL = None
if 'resultUrl' in res:
dlURL = res["resultUrl"]
elif 'responseUrl' in res:
dlURL = res["responseUrl"]
elif 'URL' in res:
dlURL = res["URL"]
if dlURL is not None:
return self._get(url=dlURL,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
out_folder=out_path)
else:
return res
elif res is not None:
return res
return None | [
"def",
"createReplica",
"(",
"self",
",",
"replicaName",
",",
"layers",
",",
"layerQueries",
"=",
"None",
",",
"geometryFilter",
"=",
"None",
",",
"replicaSR",
"=",
"None",
",",
"transportType",
"=",
"\"esriTransportTypeUrl\"",
",",
"returnAttachments",
"=",
"False",
",",
"returnAttachmentsDatabyURL",
"=",
"False",
",",
"async",
"=",
"False",
",",
"attachmentsSyncDirection",
"=",
"\"none\"",
",",
"syncModel",
"=",
"\"none\"",
",",
"dataFormat",
"=",
"\"json\"",
",",
"replicaOptions",
"=",
"None",
",",
"wait",
"=",
"False",
",",
"out_path",
"=",
"None",
")",
":",
"if",
"self",
".",
"syncEnabled",
"==",
"False",
"and",
"\"Extract\"",
"not",
"in",
"self",
".",
"capabilities",
":",
"return",
"None",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/createReplica\"",
"dataformat",
"=",
"[",
"\"filegdb\"",
",",
"\"json\"",
",",
"\"sqlite\"",
",",
"\"shapefile\"",
"]",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"replicaName\"",
":",
"replicaName",
",",
"\"returnAttachments\"",
":",
"returnAttachments",
",",
"\"returnAttachmentsDatabyURL\"",
":",
"returnAttachmentsDatabyURL",
",",
"\"attachmentsSyncDirection\"",
":",
"attachmentsSyncDirection",
",",
"\"async\"",
":",
"async",
",",
"\"syncModel\"",
":",
"syncModel",
",",
"\"layers\"",
":",
"layers",
"}",
"if",
"dataFormat",
".",
"lower",
"(",
")",
"in",
"dataformat",
":",
"params",
"[",
"'dataFormat'",
"]",
"=",
"dataFormat",
".",
"lower",
"(",
")",
"else",
":",
"raise",
"Exception",
"(",
"\"Invalid dataFormat\"",
")",
"if",
"layerQueries",
"is",
"not",
"None",
":",
"params",
"[",
"'layerQueries'",
"]",
"=",
"layerQueries",
"if",
"geometryFilter",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"geometryFilter",
",",
"GeometryFilter",
")",
":",
"params",
".",
"update",
"(",
"geometryFilter",
".",
"filter",
")",
"if",
"replicaSR",
"is",
"not",
"None",
":",
"params",
"[",
"'replicaSR'",
"]",
"=",
"replicaSR",
"if",
"replicaOptions",
"is",
"not",
"None",
":",
"params",
"[",
"'replicaOptions'",
"]",
"=",
"replicaOptions",
"if",
"transportType",
"is",
"not",
"None",
":",
"params",
"[",
"'transportType'",
"]",
"=",
"transportType",
"if",
"async",
":",
"if",
"wait",
":",
"exportJob",
"=",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"status",
"=",
"self",
".",
"replicaStatus",
"(",
"url",
"=",
"exportJob",
"[",
"'statusUrl'",
"]",
")",
"while",
"status",
"[",
"'status'",
"]",
".",
"lower",
"(",
")",
"!=",
"\"completed\"",
":",
"status",
"=",
"self",
".",
"replicaStatus",
"(",
"url",
"=",
"exportJob",
"[",
"'statusUrl'",
"]",
")",
"if",
"status",
"[",
"'status'",
"]",
".",
"lower",
"(",
")",
"==",
"\"failed\"",
":",
"return",
"status",
"res",
"=",
"status",
"else",
":",
"res",
"=",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"else",
":",
"res",
"=",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"if",
"out_path",
"is",
"not",
"None",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"out_path",
")",
":",
"dlURL",
"=",
"None",
"if",
"'resultUrl'",
"in",
"res",
":",
"dlURL",
"=",
"res",
"[",
"\"resultUrl\"",
"]",
"elif",
"'responseUrl'",
"in",
"res",
":",
"dlURL",
"=",
"res",
"[",
"\"responseUrl\"",
"]",
"elif",
"'URL'",
"in",
"res",
":",
"dlURL",
"=",
"res",
"[",
"\"URL\"",
"]",
"if",
"dlURL",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"dlURL",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"out_folder",
"=",
"out_path",
")",
"else",
":",
"return",
"res",
"elif",
"res",
"is",
"not",
"None",
":",
"return",
"res",
"return",
"None"
] | The createReplica operation is performed on a feature service
resource. This operation creates the replica between the feature
service and a client based on a client-supplied replica definition.
It requires the Sync capability. See Sync overview for more
information on sync. The response for createReplica includes
replicaID, server generation number, and data similar to the
response from the feature service query operation.
The createReplica operation returns a response of type
esriReplicaResponseTypeData, as the response has data for the
layers in the replica. If the operation is called to register
existing data by using replicaOptions, the response type will be
esriReplicaResponseTypeInfo, and the response will not contain data
for the layers in the replica.
Inputs:
replicaName - name of the replica
layers - layers to export
layerQueries - In addition to the layers and geometry parameters, the layerQueries
parameter can be used to further define what is replicated. This
parameter allows you to set properties on a per layer or per table
basis. Only the properties for the layers and tables that you want
changed from the default are required.
Example:
layerQueries = {"0":{"queryOption": "useFilter", "useGeometry": true,
"where": "requires_inspection = Yes"}}
geometryFilter - Geospatial filter applied to the replica to
parse down data output.
returnAttachments - If true, attachments are added to the replica and returned in the
response. Otherwise, attachments are not included.
returnAttachmentDatabyURL - If true, a reference to a URL will be provided for each
attachment returned from createReplica. Otherwise,
attachments are embedded in the response.
replicaSR - the spatial reference of the replica geometry.
transportType - The transportType represents the response format. If the
transportType is esriTransportTypeUrl, the JSON response is contained in a file,
and the URL link to the file is returned. Otherwise, the JSON object is returned
directly. The default is esriTransportTypeUrl.
If async is true, the results will always be returned as if transportType is
esriTransportTypeUrl. If dataFormat is sqlite, the transportFormat will always be
esriTransportTypeUrl regardless of how the parameter is set.
Values: esriTransportTypeUrl | esriTransportTypeEmbedded
returnAttachments - If true, attachments are added to the replica and returned in
the response. Otherwise, attachments are not included. The default is false. This
parameter is only applicable if the feature service has attachments.
returnAttachmentsDatabyURL - If true, a reference to a URL will be provided for
each attachment returned from createReplica. Otherwise, attachments are embedded
in the response. The default is true. This parameter is only applicable if the
feature service has attachments and if returnAttachments is true.
attachmentsSyncDirection - Client can specify the attachmentsSyncDirection when
creating a replica. AttachmentsSyncDirection is currently a createReplica property
and cannot be overridden during sync.
Values: none, upload, bidirectional
async - If true, the request is processed as an asynchronous job, and a URL is
returned that a client can visit to check the status of the job. See the topic on
asynchronous usage for more information. The default is false.
syncModel - Client can specify the attachmentsSyncDirection when creating a replica.
AttachmentsSyncDirection is currently a createReplica property and cannot be
overridden during sync.
dataFormat - The format of the replica geodatabase returned in the response. The
default is json.
Values: filegdb, json, sqlite, shapefile
replicaOptions - This parameter instructs the createReplica operation to create a
new replica based on an existing replica definition (refReplicaId). It can be used
to specify parameters for registration of existing data for sync. The operation
will create a replica but will not return data. The responseType returned in the
createReplica response will be esriReplicaResponseTypeInfo.
wait - if async, wait to pause the process until the async operation is completed.
out_path - folder path to save the file | [
"The",
"createReplica",
"operation",
"is",
"performed",
"on",
"a",
"feature",
"service",
"resource",
".",
"This",
"operation",
"creates",
"the",
"replica",
"between",
"the",
"feature",
"service",
"and",
"a",
"client",
"based",
"on",
"a",
"client",
"-",
"supplied",
"replica",
"definition",
".",
"It",
"requires",
"the",
"Sync",
"capability",
".",
"See",
"Sync",
"overview",
"for",
"more",
"information",
"on",
"sync",
".",
"The",
"response",
"for",
"createReplica",
"includes",
"replicaID",
"server",
"generation",
"number",
"and",
"data",
"similar",
"to",
"the",
"response",
"from",
"the",
"feature",
"service",
"query",
"operation",
".",
"The",
"createReplica",
"operation",
"returns",
"a",
"response",
"of",
"type",
"esriReplicaResponseTypeData",
"as",
"the",
"response",
"has",
"data",
"for",
"the",
"layers",
"in",
"the",
"replica",
".",
"If",
"the",
"operation",
"is",
"called",
"to",
"register",
"existing",
"data",
"by",
"using",
"replicaOptions",
"the",
"response",
"type",
"will",
"be",
"esriReplicaResponseTypeInfo",
"and",
"the",
"response",
"will",
"not",
"contain",
"data",
"for",
"the",
"layers",
"in",
"the",
"replica",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L631-L794 | train |
Esri/ArcREST | src/arcrest/agol/services.py | FeatureService.replicaStatus | def replicaStatus(self, url):
"""gets the replica status when exported async set to True"""
params = {"f" : "json"}
url = url + "/status"
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url) | python | def replicaStatus(self, url):
"""gets the replica status when exported async set to True"""
params = {"f" : "json"}
url = url + "/status"
return self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url) | [
"def",
"replicaStatus",
"(",
"self",
",",
"url",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"url",
"=",
"url",
"+",
"\"/status\"",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")"
] | gets the replica status when exported async set to True | [
"gets",
"the",
"replica",
"status",
"when",
"exported",
"async",
"set",
"to",
"True"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L827-L835 | train |
Esri/ArcREST | src/arcrest/agol/services.py | FeatureLayer.listAttachments | def listAttachments(self, oid):
""" list attachements for a given OBJECT ID """
url = self._url + "/%s/attachments" % oid
params = {
"f":"json"
}
return self._get(url, params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url) | python | def listAttachments(self, oid):
""" list attachements for a given OBJECT ID """
url = self._url + "/%s/attachments" % oid
params = {
"f":"json"
}
return self._get(url, params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url) | [
"def",
"listAttachments",
"(",
"self",
",",
"oid",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/%s/attachments\"",
"%",
"oid",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"return",
"self",
".",
"_get",
"(",
"url",
",",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")"
] | list attachements for a given OBJECT ID | [
"list",
"attachements",
"for",
"a",
"given",
"OBJECT",
"ID"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L1539-L1548 | train |
Esri/ArcREST | src/arcrest/agol/services.py | FeatureLayer.getAttachment | def getAttachment(self, oid, attachment_id, out_folder=None):
"""
downloads a feature's attachment.
Inputs:
oid - object id of the feature
attachment_id - ID of the attachment. Should be an integer.
out_folder - save path of the file
Output:
string - full path of the file
"""
attachments = self.listAttachments(oid=oid)
if "attachmentInfos" in attachments:
for attachment in attachments['attachmentInfos']:
if "id" in attachment and \
attachment['id'] == attachment_id:
url = self._url + "/%s/attachments/%s" % (oid, attachment_id)
return self._get(url=url, param_dict={"f":'json'},
securityHandler=self._securityHandler,
out_folder=out_folder,
file_name=attachment['name'])
return None | python | def getAttachment(self, oid, attachment_id, out_folder=None):
"""
downloads a feature's attachment.
Inputs:
oid - object id of the feature
attachment_id - ID of the attachment. Should be an integer.
out_folder - save path of the file
Output:
string - full path of the file
"""
attachments = self.listAttachments(oid=oid)
if "attachmentInfos" in attachments:
for attachment in attachments['attachmentInfos']:
if "id" in attachment and \
attachment['id'] == attachment_id:
url = self._url + "/%s/attachments/%s" % (oid, attachment_id)
return self._get(url=url, param_dict={"f":'json'},
securityHandler=self._securityHandler,
out_folder=out_folder,
file_name=attachment['name'])
return None | [
"def",
"getAttachment",
"(",
"self",
",",
"oid",
",",
"attachment_id",
",",
"out_folder",
"=",
"None",
")",
":",
"attachments",
"=",
"self",
".",
"listAttachments",
"(",
"oid",
"=",
"oid",
")",
"if",
"\"attachmentInfos\"",
"in",
"attachments",
":",
"for",
"attachment",
"in",
"attachments",
"[",
"'attachmentInfos'",
"]",
":",
"if",
"\"id\"",
"in",
"attachment",
"and",
"attachment",
"[",
"'id'",
"]",
"==",
"attachment_id",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/%s/attachments/%s\"",
"%",
"(",
"oid",
",",
"attachment_id",
")",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"{",
"\"f\"",
":",
"'json'",
"}",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"out_folder",
"=",
"out_folder",
",",
"file_name",
"=",
"attachment",
"[",
"'name'",
"]",
")",
"return",
"None"
] | downloads a feature's attachment.
Inputs:
oid - object id of the feature
attachment_id - ID of the attachment. Should be an integer.
out_folder - save path of the file
Output:
string - full path of the file | [
"downloads",
"a",
"feature",
"s",
"attachment",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L1550-L1571 | train |
Esri/ArcREST | src/arcrest/agol/services.py | FeatureLayer.create_fc_template | def create_fc_template(self, out_path, out_name):
"""creates a featureclass template on local disk"""
fields = self.fields
objectIdField = self.objectIdField
geomType = self.geometryType
wkid = self.parentLayer.spatialReference['wkid']
return create_feature_class(out_path,
out_name,
geomType,
wkid,
fields,
objectIdField) | python | def create_fc_template(self, out_path, out_name):
"""creates a featureclass template on local disk"""
fields = self.fields
objectIdField = self.objectIdField
geomType = self.geometryType
wkid = self.parentLayer.spatialReference['wkid']
return create_feature_class(out_path,
out_name,
geomType,
wkid,
fields,
objectIdField) | [
"def",
"create_fc_template",
"(",
"self",
",",
"out_path",
",",
"out_name",
")",
":",
"fields",
"=",
"self",
".",
"fields",
"objectIdField",
"=",
"self",
".",
"objectIdField",
"geomType",
"=",
"self",
".",
"geometryType",
"wkid",
"=",
"self",
".",
"parentLayer",
".",
"spatialReference",
"[",
"'wkid'",
"]",
"return",
"create_feature_class",
"(",
"out_path",
",",
"out_name",
",",
"geomType",
",",
"wkid",
",",
"fields",
",",
"objectIdField",
")"
] | creates a featureclass template on local disk | [
"creates",
"a",
"featureclass",
"template",
"on",
"local",
"disk"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L1573-L1584 | train |
Esri/ArcREST | src/arcrest/agol/services.py | FeatureLayer.create_feature_template | def create_feature_template(self):
"""creates a feature template"""
fields = self.fields
feat_schema = {}
att = {}
for fld in fields:
self._globalIdField
if not fld['name'] == self._objectIdField and not fld['name'] == self._globalIdField:
att[fld['name']] = ''
feat_schema['attributes'] = att
feat_schema['geometry'] = ''
return Feature(feat_schema) | python | def create_feature_template(self):
"""creates a feature template"""
fields = self.fields
feat_schema = {}
att = {}
for fld in fields:
self._globalIdField
if not fld['name'] == self._objectIdField and not fld['name'] == self._globalIdField:
att[fld['name']] = ''
feat_schema['attributes'] = att
feat_schema['geometry'] = ''
return Feature(feat_schema) | [
"def",
"create_feature_template",
"(",
"self",
")",
":",
"fields",
"=",
"self",
".",
"fields",
"feat_schema",
"=",
"{",
"}",
"att",
"=",
"{",
"}",
"for",
"fld",
"in",
"fields",
":",
"self",
".",
"_globalIdField",
"if",
"not",
"fld",
"[",
"'name'",
"]",
"==",
"self",
".",
"_objectIdField",
"and",
"not",
"fld",
"[",
"'name'",
"]",
"==",
"self",
".",
"_globalIdField",
":",
"att",
"[",
"fld",
"[",
"'name'",
"]",
"]",
"=",
"''",
"feat_schema",
"[",
"'attributes'",
"]",
"=",
"att",
"feat_schema",
"[",
"'geometry'",
"]",
"=",
"''",
"return",
"Feature",
"(",
"feat_schema",
")"
] | creates a feature template | [
"creates",
"a",
"feature",
"template"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/agol/services.py#L1585-L1598 | train |
Esri/ArcREST | src/arcrest/common/geometry.py | Point.spatialReference | def spatialReference(self):
"""returns the geometry spatial reference"""
if self._wkid == None and self._wkt is not None:
return {"wkt": self._wkt}
else:
return {"wkid": self._wkid} | python | def spatialReference(self):
"""returns the geometry spatial reference"""
if self._wkid == None and self._wkt is not None:
return {"wkt": self._wkt}
else:
return {"wkid": self._wkid} | [
"def",
"spatialReference",
"(",
"self",
")",
":",
"if",
"self",
".",
"_wkid",
"==",
"None",
"and",
"self",
".",
"_wkt",
"is",
"not",
"None",
":",
"return",
"{",
"\"wkt\"",
":",
"self",
".",
"_wkt",
"}",
"else",
":",
"return",
"{",
"\"wkid\"",
":",
"self",
".",
"_wkid",
"}"
] | returns the geometry spatial reference | [
"returns",
"the",
"geometry",
"spatial",
"reference"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/geometry.py#L107-L112 | train |
Esri/ArcREST | src/arcrest/common/geometry.py | Point.asJSON | def asJSON(self):
""" returns a geometry as JSON """
value = self._json
if value is None:
value = json.dumps(self.asDictionary,
default=_date_handler)
self._json = value
return self._json | python | def asJSON(self):
""" returns a geometry as JSON """
value = self._json
if value is None:
value = json.dumps(self.asDictionary,
default=_date_handler)
self._json = value
return self._json | [
"def",
"asJSON",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"_json",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"json",
".",
"dumps",
"(",
"self",
".",
"asDictionary",
",",
"default",
"=",
"_date_handler",
")",
"self",
".",
"_json",
"=",
"value",
"return",
"self",
".",
"_json"
] | returns a geometry as JSON | [
"returns",
"a",
"geometry",
"as",
"JSON"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/geometry.py#L120-L127 | train |
Esri/ArcREST | src/arcrest/common/geometry.py | Point.asArcPyObject | def asArcPyObject(self):
""" returns the Point as an ESRI arcpy.Point object """
if arcpyFound == False:
raise Exception("ArcPy is required to use this function")
return arcpy.AsShape(self.asDictionary, True) | python | def asArcPyObject(self):
""" returns the Point as an ESRI arcpy.Point object """
if arcpyFound == False:
raise Exception("ArcPy is required to use this function")
return arcpy.AsShape(self.asDictionary, True) | [
"def",
"asArcPyObject",
"(",
"self",
")",
":",
"if",
"arcpyFound",
"==",
"False",
":",
"raise",
"Exception",
"(",
"\"ArcPy is required to use this function\"",
")",
"return",
"arcpy",
".",
"AsShape",
"(",
"self",
".",
"asDictionary",
",",
"True",
")"
] | returns the Point as an ESRI arcpy.Point object | [
"returns",
"the",
"Point",
"as",
"an",
"ESRI",
"arcpy",
".",
"Point",
"object"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/geometry.py#L130-L134 | train |
Esri/ArcREST | src/arcrest/common/geometry.py | Point.X | def X(self, value):
"""sets the X coordinate"""
if isinstance(value, (int, float,
long, types.NoneType)):
self._x = value | python | def X(self, value):
"""sets the X coordinate"""
if isinstance(value, (int, float,
long, types.NoneType)):
self._x = value | [
"def",
"X",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"float",
",",
"long",
",",
"types",
".",
"NoneType",
")",
")",
":",
"self",
".",
"_x",
"=",
"value"
] | sets the X coordinate | [
"sets",
"the",
"X",
"coordinate"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/geometry.py#L166-L170 | train |
Esri/ArcREST | src/arcrest/common/geometry.py | Point.Y | def Y(self, value):
""" sets the Y coordinate """
if isinstance(value, (int, float,
long, types.NoneType)):
self._y = value | python | def Y(self, value):
""" sets the Y coordinate """
if isinstance(value, (int, float,
long, types.NoneType)):
self._y = value | [
"def",
"Y",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"float",
",",
"long",
",",
"types",
".",
"NoneType",
")",
")",
":",
"self",
".",
"_y",
"=",
"value"
] | sets the Y coordinate | [
"sets",
"the",
"Y",
"coordinate"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/geometry.py#L178-L182 | train |
Esri/ArcREST | src/arcrest/common/geometry.py | Point.Z | def Z(self, value):
""" sets the Z coordinate """
if isinstance(value, (int, float,
long, types.NoneType)):
self._z = value | python | def Z(self, value):
""" sets the Z coordinate """
if isinstance(value, (int, float,
long, types.NoneType)):
self._z = value | [
"def",
"Z",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"float",
",",
"long",
",",
"types",
".",
"NoneType",
")",
")",
":",
"self",
".",
"_z",
"=",
"value"
] | sets the Z coordinate | [
"sets",
"the",
"Z",
"coordinate"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/geometry.py#L190-L194 | train |
Esri/ArcREST | src/arcrest/common/geometry.py | Point.wkid | def wkid(self, value):
""" sets the wkid """
if isinstance(value, (int,
long)):
self._wkid = value | python | def wkid(self, value):
""" sets the wkid """
if isinstance(value, (int,
long)):
self._wkid = value | [
"def",
"wkid",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"self",
".",
"_wkid",
"=",
"value"
] | sets the wkid | [
"sets",
"the",
"wkid"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/geometry.py#L202-L206 | train |
Esri/ArcREST | src/arcrest/common/geometry.py | Envelope.asDictionary | def asDictionary(self):
""" returns the envelope as a dictionary """
template = {
"xmin" : self._xmin,
"ymin" : self._ymin,
"xmax" : self._xmax,
"ymax" : self._ymax,
"spatialReference" : self.spatialReference
}
if self._zmax is not None and \
self._zmin is not None:
template['zmin'] = self._zmin
template['zmax'] = self._zmax
if self._mmin is not None and \
self._mmax is not None:
template['mmax'] = self._mmax
template['mmin'] = self._mmin
return template | python | def asDictionary(self):
""" returns the envelope as a dictionary """
template = {
"xmin" : self._xmin,
"ymin" : self._ymin,
"xmax" : self._xmax,
"ymax" : self._ymax,
"spatialReference" : self.spatialReference
}
if self._zmax is not None and \
self._zmin is not None:
template['zmin'] = self._zmin
template['zmax'] = self._zmax
if self._mmin is not None and \
self._mmax is not None:
template['mmax'] = self._mmax
template['mmin'] = self._mmin
return template | [
"def",
"asDictionary",
"(",
"self",
")",
":",
"template",
"=",
"{",
"\"xmin\"",
":",
"self",
".",
"_xmin",
",",
"\"ymin\"",
":",
"self",
".",
"_ymin",
",",
"\"xmax\"",
":",
"self",
".",
"_xmax",
",",
"\"ymax\"",
":",
"self",
".",
"_ymax",
",",
"\"spatialReference\"",
":",
"self",
".",
"spatialReference",
"}",
"if",
"self",
".",
"_zmax",
"is",
"not",
"None",
"and",
"self",
".",
"_zmin",
"is",
"not",
"None",
":",
"template",
"[",
"'zmin'",
"]",
"=",
"self",
".",
"_zmin",
"template",
"[",
"'zmax'",
"]",
"=",
"self",
".",
"_zmax",
"if",
"self",
".",
"_mmin",
"is",
"not",
"None",
"and",
"self",
".",
"_mmax",
"is",
"not",
"None",
":",
"template",
"[",
"'mmax'",
"]",
"=",
"self",
".",
"_mmax",
"template",
"[",
"'mmin'",
"]",
"=",
"self",
".",
"_mmin",
"return",
"template"
] | returns the envelope as a dictionary | [
"returns",
"the",
"envelope",
"as",
"a",
"dictionary"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/geometry.py#L563-L582 | train |
Esri/ArcREST | src/arcrest/common/geometry.py | Envelope.asArcPyObject | def asArcPyObject(self):
""" returns the Envelope as an ESRI arcpy.Polygon object """
env = self.asDictionary
ring = [[
Point(env['xmin'], env['ymin'], self._wkid),
Point(env['xmax'], env['ymin'], self._wkid),
Point(env['xmax'], env['ymax'], self._wkid),
Point(env['xmin'], env['ymax'], self._wkid)
]]
return Polygon(rings=ring,
wkid=self._wkid,
wkt=self._wkid,
hasZ=False,
hasM=False).asArcPyObject | python | def asArcPyObject(self):
""" returns the Envelope as an ESRI arcpy.Polygon object """
env = self.asDictionary
ring = [[
Point(env['xmin'], env['ymin'], self._wkid),
Point(env['xmax'], env['ymin'], self._wkid),
Point(env['xmax'], env['ymax'], self._wkid),
Point(env['xmin'], env['ymax'], self._wkid)
]]
return Polygon(rings=ring,
wkid=self._wkid,
wkt=self._wkid,
hasZ=False,
hasM=False).asArcPyObject | [
"def",
"asArcPyObject",
"(",
"self",
")",
":",
"env",
"=",
"self",
".",
"asDictionary",
"ring",
"=",
"[",
"[",
"Point",
"(",
"env",
"[",
"'xmin'",
"]",
",",
"env",
"[",
"'ymin'",
"]",
",",
"self",
".",
"_wkid",
")",
",",
"Point",
"(",
"env",
"[",
"'xmax'",
"]",
",",
"env",
"[",
"'ymin'",
"]",
",",
"self",
".",
"_wkid",
")",
",",
"Point",
"(",
"env",
"[",
"'xmax'",
"]",
",",
"env",
"[",
"'ymax'",
"]",
",",
"self",
".",
"_wkid",
")",
",",
"Point",
"(",
"env",
"[",
"'xmin'",
"]",
",",
"env",
"[",
"'ymax'",
"]",
",",
"self",
".",
"_wkid",
")",
"]",
"]",
"return",
"Polygon",
"(",
"rings",
"=",
"ring",
",",
"wkid",
"=",
"self",
".",
"_wkid",
",",
"wkt",
"=",
"self",
".",
"_wkid",
",",
"hasZ",
"=",
"False",
",",
"hasM",
"=",
"False",
")",
".",
"asArcPyObject"
] | returns the Envelope as an ESRI arcpy.Polygon object | [
"returns",
"the",
"Envelope",
"as",
"an",
"ESRI",
"arcpy",
".",
"Polygon",
"object"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/geometry.py#L621-L634 | train |
Esri/ArcREST | src/arcrest/opendata/_web.py | WebOperations._process_response | def _process_response(self, resp, out_folder=None):
""" processes the response object"""
CHUNK = 4056
maintype = self._mainType(resp)
contentDisposition = resp.headers.get('content-disposition')
contentEncoding = resp.headers.get('content-encoding')
contentType = resp.headers.get('content-type')
contentLength = resp.headers.get('content-length')
if maintype.lower() in ('image',
'application/x-zip-compressed') or \
contentType == 'application/x-zip-compressed' or \
(contentDisposition is not None and \
contentDisposition.lower().find('attachment;') > -1):
fname = self._get_file_name(
contentDisposition=contentDisposition,
url=resp.geturl())
if out_folder is None:
out_folder = tempfile.gettempdir()
if contentLength is not None:
max_length = int(contentLength)
if max_length < CHUNK:
CHUNK = max_length
file_name = os.path.join(out_folder, fname)
with open(file_name, 'wb') as writer:
for data in self._chunk(response=resp):
writer.write(data)
del data
del writer
return file_name
else:
read = ""
for data in self._chunk(response=resp, size=4096):
if self.PY3 == True:
read += data.decode('utf-8')
else:
read += data
del data
try:
return json.loads(read.strip())
except:
return read
return None | python | def _process_response(self, resp, out_folder=None):
""" processes the response object"""
CHUNK = 4056
maintype = self._mainType(resp)
contentDisposition = resp.headers.get('content-disposition')
contentEncoding = resp.headers.get('content-encoding')
contentType = resp.headers.get('content-type')
contentLength = resp.headers.get('content-length')
if maintype.lower() in ('image',
'application/x-zip-compressed') or \
contentType == 'application/x-zip-compressed' or \
(contentDisposition is not None and \
contentDisposition.lower().find('attachment;') > -1):
fname = self._get_file_name(
contentDisposition=contentDisposition,
url=resp.geturl())
if out_folder is None:
out_folder = tempfile.gettempdir()
if contentLength is not None:
max_length = int(contentLength)
if max_length < CHUNK:
CHUNK = max_length
file_name = os.path.join(out_folder, fname)
with open(file_name, 'wb') as writer:
for data in self._chunk(response=resp):
writer.write(data)
del data
del writer
return file_name
else:
read = ""
for data in self._chunk(response=resp, size=4096):
if self.PY3 == True:
read += data.decode('utf-8')
else:
read += data
del data
try:
return json.loads(read.strip())
except:
return read
return None | [
"def",
"_process_response",
"(",
"self",
",",
"resp",
",",
"out_folder",
"=",
"None",
")",
":",
"CHUNK",
"=",
"4056",
"maintype",
"=",
"self",
".",
"_mainType",
"(",
"resp",
")",
"contentDisposition",
"=",
"resp",
".",
"headers",
".",
"get",
"(",
"'content-disposition'",
")",
"contentEncoding",
"=",
"resp",
".",
"headers",
".",
"get",
"(",
"'content-encoding'",
")",
"contentType",
"=",
"resp",
".",
"headers",
".",
"get",
"(",
"'content-type'",
")",
"contentLength",
"=",
"resp",
".",
"headers",
".",
"get",
"(",
"'content-length'",
")",
"if",
"maintype",
".",
"lower",
"(",
")",
"in",
"(",
"'image'",
",",
"'application/x-zip-compressed'",
")",
"or",
"contentType",
"==",
"'application/x-zip-compressed'",
"or",
"(",
"contentDisposition",
"is",
"not",
"None",
"and",
"contentDisposition",
".",
"lower",
"(",
")",
".",
"find",
"(",
"'attachment;'",
")",
">",
"-",
"1",
")",
":",
"fname",
"=",
"self",
".",
"_get_file_name",
"(",
"contentDisposition",
"=",
"contentDisposition",
",",
"url",
"=",
"resp",
".",
"geturl",
"(",
")",
")",
"if",
"out_folder",
"is",
"None",
":",
"out_folder",
"=",
"tempfile",
".",
"gettempdir",
"(",
")",
"if",
"contentLength",
"is",
"not",
"None",
":",
"max_length",
"=",
"int",
"(",
"contentLength",
")",
"if",
"max_length",
"<",
"CHUNK",
":",
"CHUNK",
"=",
"max_length",
"file_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_folder",
",",
"fname",
")",
"with",
"open",
"(",
"file_name",
",",
"'wb'",
")",
"as",
"writer",
":",
"for",
"data",
"in",
"self",
".",
"_chunk",
"(",
"response",
"=",
"resp",
")",
":",
"writer",
".",
"write",
"(",
"data",
")",
"del",
"data",
"del",
"writer",
"return",
"file_name",
"else",
":",
"read",
"=",
"\"\"",
"for",
"data",
"in",
"self",
".",
"_chunk",
"(",
"response",
"=",
"resp",
",",
"size",
"=",
"4096",
")",
":",
"if",
"self",
".",
"PY3",
"==",
"True",
":",
"read",
"+=",
"data",
".",
"decode",
"(",
"'utf-8'",
")",
"else",
":",
"read",
"+=",
"data",
"del",
"data",
"try",
":",
"return",
"json",
".",
"loads",
"(",
"read",
".",
"strip",
"(",
")",
")",
"except",
":",
"return",
"read",
"return",
"None"
] | processes the response object | [
"processes",
"the",
"response",
"object"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/opendata/_web.py#L238-L279 | train |
Esri/ArcREST | src/arcrest/manageags/_security.py | Security.addUsersToRole | def addUsersToRole(self, rolename, users):
""" Assigns a role to multiple users """
params = {
"f" : "json",
"rolename" : rolename,
"users" : users
}
rURL = self._url + "/roles/addUsersToRole"
return self._post(url=rURL, param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def addUsersToRole(self, rolename, users):
""" Assigns a role to multiple users """
params = {
"f" : "json",
"rolename" : rolename,
"users" : users
}
rURL = self._url + "/roles/addUsersToRole"
return self._post(url=rURL, param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"addUsersToRole",
"(",
"self",
",",
"rolename",
",",
"users",
")",
":",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
",",
"\"rolename\"",
":",
"rolename",
",",
"\"users\"",
":",
"users",
"}",
"rURL",
"=",
"self",
".",
"_url",
"+",
"\"/roles/addUsersToRole\"",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"rURL",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | Assigns a role to multiple users | [
"Assigns",
"a",
"role",
"to",
"multiple",
"users"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_security.py#L156-L167 | train |
Esri/ArcREST | src/arcrest/manageags/_system.py | System.serverProperties | def serverProperties(self):
"""gets the server properties for the site as an object"""
return ServerProperties(url=self._url + "/properties",
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True) | python | def serverProperties(self):
"""gets the server properties for the site as an object"""
return ServerProperties(url=self._url + "/properties",
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True) | [
"def",
"serverProperties",
"(",
"self",
")",
":",
"return",
"ServerProperties",
"(",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/properties\"",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")"
] | gets the server properties for the site as an object | [
"gets",
"the",
"server",
"properties",
"for",
"the",
"site",
"as",
"an",
"object"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_system.py#L69-L75 | train |
Esri/ArcREST | src/arcrest/manageags/_system.py | System.serverDirectories | def serverDirectories(self):
"""returns the server directory object in a list"""
directs = []
url = self._url + "/directories"
params = {
"f" : "json"
}
res = self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
for direct in res['directories']:
directs.append(
ServerDirectory(url=url + "/%s" % direct["name"],
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True))
return directs | python | def serverDirectories(self):
"""returns the server directory object in a list"""
directs = []
url = self._url + "/directories"
params = {
"f" : "json"
}
res = self._get(url=url,
param_dict=params,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
for direct in res['directories']:
directs.append(
ServerDirectory(url=url + "/%s" % direct["name"],
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True))
return directs | [
"def",
"serverDirectories",
"(",
"self",
")",
":",
"directs",
"=",
"[",
"]",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/directories\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"res",
"=",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"for",
"direct",
"in",
"res",
"[",
"'directories'",
"]",
":",
"directs",
".",
"append",
"(",
"ServerDirectory",
"(",
"url",
"=",
"url",
"+",
"\"/%s\"",
"%",
"direct",
"[",
"\"name\"",
"]",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")",
")",
"return",
"directs"
] | returns the server directory object in a list | [
"returns",
"the",
"server",
"directory",
"object",
"in",
"a",
"list"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_system.py#L78-L97 | train |
Esri/ArcREST | src/arcrest/manageags/_system.py | System.Jobs | def Jobs(self):
"""get the Jobs object"""
url = self._url + "/jobs"
return Jobs(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True) | python | def Jobs(self):
"""get the Jobs object"""
url = self._url + "/jobs"
return Jobs(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initialize=True) | [
"def",
"Jobs",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/jobs\"",
"return",
"Jobs",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initialize",
"=",
"True",
")"
] | get the Jobs object | [
"get",
"the",
"Jobs",
"object"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_system.py#L218-L225 | train |
Esri/ArcREST | src/arcrest/manageags/_system.py | System.configurationStore | def configurationStore(self):
"""returns the ConfigurationStore object for this site"""
url = self._url + "/configstore"
return ConfigurationStore(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def configurationStore(self):
"""returns the ConfigurationStore object for this site"""
url = self._url + "/configstore"
return ConfigurationStore(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"configurationStore",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/configstore\"",
"return",
"ConfigurationStore",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | returns the ConfigurationStore object for this site | [
"returns",
"the",
"ConfigurationStore",
"object",
"for",
"this",
"site"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageags/_system.py#L351-L358 | train |
Esri/ArcREST | src/arcresthelper/featureservicetools.py | featureservicetools.EnableEditingOnService | def EnableEditingOnService(self, url, definition = None):
"""Enables editing capabilities on a feature service.
Args:
url (str): The URL of the feature service.
definition (dict): A dictionary containing valid definition values. Defaults to ``None``.
Returns:
dict: The existing feature service definition capabilities.
When ``definition`` is not provided (``None``), the following values are used by default:
+------------------------------+------------------------------------------+
| Key | Value |
+------------------------------+------------------------------------------+
| hasStaticData | ``False`` |
+------------------------------+------------------------------------------+
| allowGeometryUpdates | ``True`` |
+------------------------------+------------------------------------------+
| enableEditorTracking | ``False`` |
+------------------------------+------------------------------------------+
| enableOwnershipAccessControl | ``False`` |
+------------------------------+------------------------------------------+
| allowOthersToUpdate | ``True`` |
+------------------------------+------------------------------------------+
| allowOthersToDelete | ``True`` |
+------------------------------+------------------------------------------+
| capabilities | ``"Query,Editing,Create,Update,Delete"`` |
+------------------------------+------------------------------------------+
"""
adminFS = AdminFeatureService(url=url, securityHandler=self._securityHandler)
if definition is None:
definition = collections.OrderedDict()
definition['hasStaticData'] = False
definition['allowGeometryUpdates'] = True
definition['editorTrackingInfo'] = {}
definition['editorTrackingInfo']['enableEditorTracking'] = False
definition['editorTrackingInfo']['enableOwnershipAccessControl'] = False
definition['editorTrackingInfo']['allowOthersToUpdate'] = True
definition['editorTrackingInfo']['allowOthersToDelete'] = True
definition['capabilities'] = "Query,Editing,Create,Update,Delete"
existingDef = {}
existingDef['capabilities'] = adminFS.capabilities
existingDef['allowGeometryUpdates'] = adminFS.allowGeometryUpdates
enableResults = adminFS.updateDefinition(json_dict=definition)
if 'error' in enableResults:
return enableResults['error']
adminFS = None
del adminFS
print (enableResults)
return existingDef | python | def EnableEditingOnService(self, url, definition = None):
"""Enables editing capabilities on a feature service.
Args:
url (str): The URL of the feature service.
definition (dict): A dictionary containing valid definition values. Defaults to ``None``.
Returns:
dict: The existing feature service definition capabilities.
When ``definition`` is not provided (``None``), the following values are used by default:
+------------------------------+------------------------------------------+
| Key | Value |
+------------------------------+------------------------------------------+
| hasStaticData | ``False`` |
+------------------------------+------------------------------------------+
| allowGeometryUpdates | ``True`` |
+------------------------------+------------------------------------------+
| enableEditorTracking | ``False`` |
+------------------------------+------------------------------------------+
| enableOwnershipAccessControl | ``False`` |
+------------------------------+------------------------------------------+
| allowOthersToUpdate | ``True`` |
+------------------------------+------------------------------------------+
| allowOthersToDelete | ``True`` |
+------------------------------+------------------------------------------+
| capabilities | ``"Query,Editing,Create,Update,Delete"`` |
+------------------------------+------------------------------------------+
"""
adminFS = AdminFeatureService(url=url, securityHandler=self._securityHandler)
if definition is None:
definition = collections.OrderedDict()
definition['hasStaticData'] = False
definition['allowGeometryUpdates'] = True
definition['editorTrackingInfo'] = {}
definition['editorTrackingInfo']['enableEditorTracking'] = False
definition['editorTrackingInfo']['enableOwnershipAccessControl'] = False
definition['editorTrackingInfo']['allowOthersToUpdate'] = True
definition['editorTrackingInfo']['allowOthersToDelete'] = True
definition['capabilities'] = "Query,Editing,Create,Update,Delete"
existingDef = {}
existingDef['capabilities'] = adminFS.capabilities
existingDef['allowGeometryUpdates'] = adminFS.allowGeometryUpdates
enableResults = adminFS.updateDefinition(json_dict=definition)
if 'error' in enableResults:
return enableResults['error']
adminFS = None
del adminFS
print (enableResults)
return existingDef | [
"def",
"EnableEditingOnService",
"(",
"self",
",",
"url",
",",
"definition",
"=",
"None",
")",
":",
"adminFS",
"=",
"AdminFeatureService",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
")",
"if",
"definition",
"is",
"None",
":",
"definition",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"definition",
"[",
"'hasStaticData'",
"]",
"=",
"False",
"definition",
"[",
"'allowGeometryUpdates'",
"]",
"=",
"True",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"=",
"{",
"}",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'enableEditorTracking'",
"]",
"=",
"False",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'enableOwnershipAccessControl'",
"]",
"=",
"False",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'allowOthersToUpdate'",
"]",
"=",
"True",
"definition",
"[",
"'editorTrackingInfo'",
"]",
"[",
"'allowOthersToDelete'",
"]",
"=",
"True",
"definition",
"[",
"'capabilities'",
"]",
"=",
"\"Query,Editing,Create,Update,Delete\"",
"existingDef",
"=",
"{",
"}",
"existingDef",
"[",
"'capabilities'",
"]",
"=",
"adminFS",
".",
"capabilities",
"existingDef",
"[",
"'allowGeometryUpdates'",
"]",
"=",
"adminFS",
".",
"allowGeometryUpdates",
"enableResults",
"=",
"adminFS",
".",
"updateDefinition",
"(",
"json_dict",
"=",
"definition",
")",
"if",
"'error'",
"in",
"enableResults",
":",
"return",
"enableResults",
"[",
"'error'",
"]",
"adminFS",
"=",
"None",
"del",
"adminFS",
"print",
"(",
"enableResults",
")",
"return",
"existingDef"
] | Enables editing capabilities on a feature service.
Args:
url (str): The URL of the feature service.
definition (dict): A dictionary containing valid definition values. Defaults to ``None``.
Returns:
dict: The existing feature service definition capabilities.
When ``definition`` is not provided (``None``), the following values are used by default:
+------------------------------+------------------------------------------+
| Key | Value |
+------------------------------+------------------------------------------+
| hasStaticData | ``False`` |
+------------------------------+------------------------------------------+
| allowGeometryUpdates | ``True`` |
+------------------------------+------------------------------------------+
| enableEditorTracking | ``False`` |
+------------------------------+------------------------------------------+
| enableOwnershipAccessControl | ``False`` |
+------------------------------+------------------------------------------+
| allowOthersToUpdate | ``True`` |
+------------------------------+------------------------------------------+
| allowOthersToDelete | ``True`` |
+------------------------------+------------------------------------------+
| capabilities | ``"Query,Editing,Create,Update,Delete"`` |
+------------------------------+------------------------------------------+ | [
"Enables",
"editing",
"capabilities",
"on",
"a",
"feature",
"service",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/featureservicetools.py#L197-L252 | train |
Esri/ArcREST | src/arcresthelper/featureservicetools.py | featureservicetools.enableSync | def enableSync(self, url, definition = None):
"""Enables Sync capability for an AGOL feature service.
Args:
url (str): The URL of the feature service.
definition (dict): A dictionary containing valid definition values. Defaults to ``None``.
Returns:
dict: The result from :py:func:`arcrest.hostedservice.service.AdminFeatureService.updateDefinition`.
"""
adminFS = AdminFeatureService(url=url, securityHandler=self._securityHandler)
cap = str(adminFS.capabilities)
existingDef = {}
enableResults = 'skipped'
if 'Sync' in cap:
return "Sync is already enabled"
else:
capItems = cap.split(',')
capItems.append('Sync')
existingDef['capabilities'] = ','.join(capItems)
enableResults = adminFS.updateDefinition(json_dict=existingDef)
if 'error' in enableResults:
return enableResults['error']
adminFS = None
del adminFS
return enableResults | python | def enableSync(self, url, definition = None):
"""Enables Sync capability for an AGOL feature service.
Args:
url (str): The URL of the feature service.
definition (dict): A dictionary containing valid definition values. Defaults to ``None``.
Returns:
dict: The result from :py:func:`arcrest.hostedservice.service.AdminFeatureService.updateDefinition`.
"""
adminFS = AdminFeatureService(url=url, securityHandler=self._securityHandler)
cap = str(adminFS.capabilities)
existingDef = {}
enableResults = 'skipped'
if 'Sync' in cap:
return "Sync is already enabled"
else:
capItems = cap.split(',')
capItems.append('Sync')
existingDef['capabilities'] = ','.join(capItems)
enableResults = adminFS.updateDefinition(json_dict=existingDef)
if 'error' in enableResults:
return enableResults['error']
adminFS = None
del adminFS
return enableResults | [
"def",
"enableSync",
"(",
"self",
",",
"url",
",",
"definition",
"=",
"None",
")",
":",
"adminFS",
"=",
"AdminFeatureService",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
")",
"cap",
"=",
"str",
"(",
"adminFS",
".",
"capabilities",
")",
"existingDef",
"=",
"{",
"}",
"enableResults",
"=",
"'skipped'",
"if",
"'Sync'",
"in",
"cap",
":",
"return",
"\"Sync is already enabled\"",
"else",
":",
"capItems",
"=",
"cap",
".",
"split",
"(",
"','",
")",
"capItems",
".",
"append",
"(",
"'Sync'",
")",
"existingDef",
"[",
"'capabilities'",
"]",
"=",
"','",
".",
"join",
"(",
"capItems",
")",
"enableResults",
"=",
"adminFS",
".",
"updateDefinition",
"(",
"json_dict",
"=",
"existingDef",
")",
"if",
"'error'",
"in",
"enableResults",
":",
"return",
"enableResults",
"[",
"'error'",
"]",
"adminFS",
"=",
"None",
"del",
"adminFS",
"return",
"enableResults"
] | Enables Sync capability for an AGOL feature service.
Args:
url (str): The URL of the feature service.
definition (dict): A dictionary containing valid definition values. Defaults to ``None``.
Returns:
dict: The result from :py:func:`arcrest.hostedservice.service.AdminFeatureService.updateDefinition`. | [
"Enables",
"Sync",
"capability",
"for",
"an",
"AGOL",
"feature",
"service",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/featureservicetools.py#L254-L281 | train |
Esri/ArcREST | src/arcresthelper/featureservicetools.py | featureservicetools.GetFeatureService | def GetFeatureService(self, itemId, returnURLOnly=False):
"""Obtains a feature service by item ID.
Args:
itemId (str): The feature service's item ID.
returnURLOnly (bool): A boolean value to return the URL of the feature service. Defaults to ``False``.
Returns:
When ``returnURLOnly`` is ``True``, the URL of the feature service is returned.
When ``False``, the result from :py:func:`arcrest.agol.services.FeatureService` or :py:func:`arcrest.ags.services.FeatureService`.
"""
admin = None
item = None
try:
admin = arcrest.manageorg.Administration(securityHandler=self._securityHandler)
if self._securityHandler.valid == False:
self._valid = self._securityHandler.valid
self._message = self._securityHandler.message
return None
item = admin.content.getItem(itemId=itemId)
if item.type == "Feature Service":
if returnURLOnly:
return item.url
else:
fs = arcrest.agol.FeatureService(
url=item.url,
securityHandler=self._securityHandler)
if fs.layers is None or len(fs.layers) == 0 :
fs = arcrest.ags.FeatureService(
url=item.url)
return fs
return None
except:
line, filename, synerror = trace()
raise common.ArcRestHelperError({
"function": "GetFeatureService",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
admin = None
item = None
del item
del admin
gc.collect() | python | def GetFeatureService(self, itemId, returnURLOnly=False):
"""Obtains a feature service by item ID.
Args:
itemId (str): The feature service's item ID.
returnURLOnly (bool): A boolean value to return the URL of the feature service. Defaults to ``False``.
Returns:
When ``returnURLOnly`` is ``True``, the URL of the feature service is returned.
When ``False``, the result from :py:func:`arcrest.agol.services.FeatureService` or :py:func:`arcrest.ags.services.FeatureService`.
"""
admin = None
item = None
try:
admin = arcrest.manageorg.Administration(securityHandler=self._securityHandler)
if self._securityHandler.valid == False:
self._valid = self._securityHandler.valid
self._message = self._securityHandler.message
return None
item = admin.content.getItem(itemId=itemId)
if item.type == "Feature Service":
if returnURLOnly:
return item.url
else:
fs = arcrest.agol.FeatureService(
url=item.url,
securityHandler=self._securityHandler)
if fs.layers is None or len(fs.layers) == 0 :
fs = arcrest.ags.FeatureService(
url=item.url)
return fs
return None
except:
line, filename, synerror = trace()
raise common.ArcRestHelperError({
"function": "GetFeatureService",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
admin = None
item = None
del item
del admin
gc.collect() | [
"def",
"GetFeatureService",
"(",
"self",
",",
"itemId",
",",
"returnURLOnly",
"=",
"False",
")",
":",
"admin",
"=",
"None",
"item",
"=",
"None",
"try",
":",
"admin",
"=",
"arcrest",
".",
"manageorg",
".",
"Administration",
"(",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
")",
"if",
"self",
".",
"_securityHandler",
".",
"valid",
"==",
"False",
":",
"self",
".",
"_valid",
"=",
"self",
".",
"_securityHandler",
".",
"valid",
"self",
".",
"_message",
"=",
"self",
".",
"_securityHandler",
".",
"message",
"return",
"None",
"item",
"=",
"admin",
".",
"content",
".",
"getItem",
"(",
"itemId",
"=",
"itemId",
")",
"if",
"item",
".",
"type",
"==",
"\"Feature Service\"",
":",
"if",
"returnURLOnly",
":",
"return",
"item",
".",
"url",
"else",
":",
"fs",
"=",
"arcrest",
".",
"agol",
".",
"FeatureService",
"(",
"url",
"=",
"item",
".",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
")",
"if",
"fs",
".",
"layers",
"is",
"None",
"or",
"len",
"(",
"fs",
".",
"layers",
")",
"==",
"0",
":",
"fs",
"=",
"arcrest",
".",
"ags",
".",
"FeatureService",
"(",
"url",
"=",
"item",
".",
"url",
")",
"return",
"fs",
"return",
"None",
"except",
":",
"line",
",",
"filename",
",",
"synerror",
"=",
"trace",
"(",
")",
"raise",
"common",
".",
"ArcRestHelperError",
"(",
"{",
"\"function\"",
":",
"\"GetFeatureService\"",
",",
"\"line\"",
":",
"line",
",",
"\"filename\"",
":",
"filename",
",",
"\"synerror\"",
":",
"synerror",
",",
"}",
")",
"finally",
":",
"admin",
"=",
"None",
"item",
"=",
"None",
"del",
"item",
"del",
"admin",
"gc",
".",
"collect",
"(",
")"
] | Obtains a feature service by item ID.
Args:
itemId (str): The feature service's item ID.
returnURLOnly (bool): A boolean value to return the URL of the feature service. Defaults to ``False``.
Returns:
When ``returnURLOnly`` is ``True``, the URL of the feature service is returned.
When ``False``, the result from :py:func:`arcrest.agol.services.FeatureService` or :py:func:`arcrest.ags.services.FeatureService`. | [
"Obtains",
"a",
"feature",
"service",
"by",
"item",
"ID",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/featureservicetools.py#L313-L362 | train |
Esri/ArcREST | src/arcresthelper/featureservicetools.py | featureservicetools.GetLayerFromFeatureServiceByURL | def GetLayerFromFeatureServiceByURL(self, url, layerName="", returnURLOnly=False):
"""Obtains a layer from a feature service by URL reference.
Args:
url (str): The URL of the feature service.
layerName (str): The name of the layer. Defaults to ``""``.
returnURLOnly (bool): A boolean value to return the URL of the layer. Defaults to ``False``.
Returns:
When ``returnURLOnly`` is ``True``, the URL of the layer is returned.
When ``False``, the result from :py:func:`arcrest.agol.services.FeatureService` or :py:func:`arcrest.ags.services.FeatureService`.
"""
fs = None
try:
fs = arcrest.agol.FeatureService(
url=url,
securityHandler=self._securityHandler)
return self.GetLayerFromFeatureService(fs=fs,layerName=layerName,returnURLOnly=returnURLOnly)
except:
line, filename, synerror = trace()
raise common.ArcRestHelperError({
"function": "GetLayerFromFeatureServiceByURL",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
fs = None
del fs
gc.collect() | python | def GetLayerFromFeatureServiceByURL(self, url, layerName="", returnURLOnly=False):
"""Obtains a layer from a feature service by URL reference.
Args:
url (str): The URL of the feature service.
layerName (str): The name of the layer. Defaults to ``""``.
returnURLOnly (bool): A boolean value to return the URL of the layer. Defaults to ``False``.
Returns:
When ``returnURLOnly`` is ``True``, the URL of the layer is returned.
When ``False``, the result from :py:func:`arcrest.agol.services.FeatureService` or :py:func:`arcrest.ags.services.FeatureService`.
"""
fs = None
try:
fs = arcrest.agol.FeatureService(
url=url,
securityHandler=self._securityHandler)
return self.GetLayerFromFeatureService(fs=fs,layerName=layerName,returnURLOnly=returnURLOnly)
except:
line, filename, synerror = trace()
raise common.ArcRestHelperError({
"function": "GetLayerFromFeatureServiceByURL",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
fs = None
del fs
gc.collect() | [
"def",
"GetLayerFromFeatureServiceByURL",
"(",
"self",
",",
"url",
",",
"layerName",
"=",
"\"\"",
",",
"returnURLOnly",
"=",
"False",
")",
":",
"fs",
"=",
"None",
"try",
":",
"fs",
"=",
"arcrest",
".",
"agol",
".",
"FeatureService",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
")",
"return",
"self",
".",
"GetLayerFromFeatureService",
"(",
"fs",
"=",
"fs",
",",
"layerName",
"=",
"layerName",
",",
"returnURLOnly",
"=",
"returnURLOnly",
")",
"except",
":",
"line",
",",
"filename",
",",
"synerror",
"=",
"trace",
"(",
")",
"raise",
"common",
".",
"ArcRestHelperError",
"(",
"{",
"\"function\"",
":",
"\"GetLayerFromFeatureServiceByURL\"",
",",
"\"line\"",
":",
"line",
",",
"\"filename\"",
":",
"filename",
",",
"\"synerror\"",
":",
"synerror",
",",
"}",
")",
"finally",
":",
"fs",
"=",
"None",
"del",
"fs",
"gc",
".",
"collect",
"(",
")"
] | Obtains a layer from a feature service by URL reference.
Args:
url (str): The URL of the feature service.
layerName (str): The name of the layer. Defaults to ``""``.
returnURLOnly (bool): A boolean value to return the URL of the layer. Defaults to ``False``.
Returns:
When ``returnURLOnly`` is ``True``, the URL of the layer is returned.
When ``False``, the result from :py:func:`arcrest.agol.services.FeatureService` or :py:func:`arcrest.ags.services.FeatureService`. | [
"Obtains",
"a",
"layer",
"from",
"a",
"feature",
"service",
"by",
"URL",
"reference",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/featureservicetools.py#L364-L397 | train |
Esri/ArcREST | src/arcresthelper/featureservicetools.py | featureservicetools.GetLayerFromFeatureService | def GetLayerFromFeatureService(self, fs, layerName="", returnURLOnly=False):
"""Obtains a layer from a feature service by feature service reference.
Args:
fs (FeatureService): The feature service from which to obtain the layer.
layerName (str): The name of the layer. Defaults to ``""``.
returnURLOnly (bool): A boolean value to return the URL of the layer. Defaults to ``False``.
Returns:
When ``returnURLOnly`` is ``True``, the URL of the layer is returned.
When ``False``, the result from :py:func:`arcrest.agol.services.FeatureService` or :py:func:`arcrest.ags.services.FeatureService`.
"""
layers = None
table = None
layer = None
sublayer = None
try:
layers = fs.layers
if (layers is None or len(layers) == 0) and fs.url is not None:
fs = arcrest.ags.FeatureService(
url=fs.url)
layers = fs.layers
if layers is not None:
for layer in layers:
if layer.name == layerName:
if returnURLOnly:
return fs.url + '/' + str(layer.id)
else:
return layer
elif not layer.subLayers is None:
for sublayer in layer.subLayers:
if sublayer == layerName:
return sublayer
if fs.tables is not None:
for table in fs.tables:
if table.name == layerName:
if returnURLOnly:
return fs.url + '/' + str(layer.id)
else:
return table
return None
except:
line, filename, synerror = trace()
raise common.ArcRestHelperError({
"function": "GetLayerFromFeatureService",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
layers = None
table = None
layer = None
sublayer = None
del layers
del table
del layer
del sublayer
gc.collect() | python | def GetLayerFromFeatureService(self, fs, layerName="", returnURLOnly=False):
"""Obtains a layer from a feature service by feature service reference.
Args:
fs (FeatureService): The feature service from which to obtain the layer.
layerName (str): The name of the layer. Defaults to ``""``.
returnURLOnly (bool): A boolean value to return the URL of the layer. Defaults to ``False``.
Returns:
When ``returnURLOnly`` is ``True``, the URL of the layer is returned.
When ``False``, the result from :py:func:`arcrest.agol.services.FeatureService` or :py:func:`arcrest.ags.services.FeatureService`.
"""
layers = None
table = None
layer = None
sublayer = None
try:
layers = fs.layers
if (layers is None or len(layers) == 0) and fs.url is not None:
fs = arcrest.ags.FeatureService(
url=fs.url)
layers = fs.layers
if layers is not None:
for layer in layers:
if layer.name == layerName:
if returnURLOnly:
return fs.url + '/' + str(layer.id)
else:
return layer
elif not layer.subLayers is None:
for sublayer in layer.subLayers:
if sublayer == layerName:
return sublayer
if fs.tables is not None:
for table in fs.tables:
if table.name == layerName:
if returnURLOnly:
return fs.url + '/' + str(layer.id)
else:
return table
return None
except:
line, filename, synerror = trace()
raise common.ArcRestHelperError({
"function": "GetLayerFromFeatureService",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
layers = None
table = None
layer = None
sublayer = None
del layers
del table
del layer
del sublayer
gc.collect() | [
"def",
"GetLayerFromFeatureService",
"(",
"self",
",",
"fs",
",",
"layerName",
"=",
"\"\"",
",",
"returnURLOnly",
"=",
"False",
")",
":",
"layers",
"=",
"None",
"table",
"=",
"None",
"layer",
"=",
"None",
"sublayer",
"=",
"None",
"try",
":",
"layers",
"=",
"fs",
".",
"layers",
"if",
"(",
"layers",
"is",
"None",
"or",
"len",
"(",
"layers",
")",
"==",
"0",
")",
"and",
"fs",
".",
"url",
"is",
"not",
"None",
":",
"fs",
"=",
"arcrest",
".",
"ags",
".",
"FeatureService",
"(",
"url",
"=",
"fs",
".",
"url",
")",
"layers",
"=",
"fs",
".",
"layers",
"if",
"layers",
"is",
"not",
"None",
":",
"for",
"layer",
"in",
"layers",
":",
"if",
"layer",
".",
"name",
"==",
"layerName",
":",
"if",
"returnURLOnly",
":",
"return",
"fs",
".",
"url",
"+",
"'/'",
"+",
"str",
"(",
"layer",
".",
"id",
")",
"else",
":",
"return",
"layer",
"elif",
"not",
"layer",
".",
"subLayers",
"is",
"None",
":",
"for",
"sublayer",
"in",
"layer",
".",
"subLayers",
":",
"if",
"sublayer",
"==",
"layerName",
":",
"return",
"sublayer",
"if",
"fs",
".",
"tables",
"is",
"not",
"None",
":",
"for",
"table",
"in",
"fs",
".",
"tables",
":",
"if",
"table",
".",
"name",
"==",
"layerName",
":",
"if",
"returnURLOnly",
":",
"return",
"fs",
".",
"url",
"+",
"'/'",
"+",
"str",
"(",
"layer",
".",
"id",
")",
"else",
":",
"return",
"table",
"return",
"None",
"except",
":",
"line",
",",
"filename",
",",
"synerror",
"=",
"trace",
"(",
")",
"raise",
"common",
".",
"ArcRestHelperError",
"(",
"{",
"\"function\"",
":",
"\"GetLayerFromFeatureService\"",
",",
"\"line\"",
":",
"line",
",",
"\"filename\"",
":",
"filename",
",",
"\"synerror\"",
":",
"synerror",
",",
"}",
")",
"finally",
":",
"layers",
"=",
"None",
"table",
"=",
"None",
"layer",
"=",
"None",
"sublayer",
"=",
"None",
"del",
"layers",
"del",
"table",
"del",
"layer",
"del",
"sublayer",
"gc",
".",
"collect",
"(",
")"
] | Obtains a layer from a feature service by feature service reference.
Args:
fs (FeatureService): The feature service from which to obtain the layer.
layerName (str): The name of the layer. Defaults to ``""``.
returnURLOnly (bool): A boolean value to return the URL of the layer. Defaults to ``False``.
Returns:
When ``returnURLOnly`` is ``True``, the URL of the layer is returned.
When ``False``, the result from :py:func:`arcrest.agol.services.FeatureService` or :py:func:`arcrest.ags.services.FeatureService`. | [
"Obtains",
"a",
"layer",
"from",
"a",
"feature",
"service",
"by",
"feature",
"service",
"reference",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/featureservicetools.py#L399-L461 | train |
Esri/ArcREST | src/arcresthelper/featureservicetools.py | featureservicetools.DeleteFeaturesFromFeatureLayer | def DeleteFeaturesFromFeatureLayer(self, url, sql, chunksize=0):
"""Removes features from a hosted feature service layer by SQL query.
Args:
url (str): The URL of the feature service layer.
sql (str): The SQL query to apply against the feature service.
Those features that satisfy the query will be deleted.
chunksize (int): The maximum amount of features to remove at a time. Defaults to 0.
Returns:
The result from :py:func:`arcrest.agol.services.FeatureLayer.deleteFeatures`.
Notes:
If you want to delete all features, it is suggested to use the SQL query ``"1=1"``.
"""
fl = None
try:
fl = FeatureLayer(
url=url,
securityHandler=self._securityHandler)
totalDeleted = 0
if chunksize > 0:
qRes = fl.query(where=sql, returnIDsOnly=True)
if 'error' in qRes:
print (qRes)
return qRes
elif 'objectIds' in qRes:
oids = qRes['objectIds']
total = len(oids)
if total == 0:
return {'success':True,'message': "No features matched the query"}
i = 0
print ("%s features to be deleted" % total)
while(i <= len(oids)):
oidsDelete = ','.join(str(e) for e in oids[i:i+chunksize])
if oidsDelete == '':
continue
else:
results = fl.deleteFeatures(objectIds=oidsDelete)
if 'deleteResults' in results:
totalDeleted += len(results['deleteResults'])
print ("%s%% Completed: %s/%s " % (int(totalDeleted / float(total) *100), totalDeleted, total))
i += chunksize
else:
print (results)
return {'success':True,'message': "%s deleted" % totalDeleted}
qRes = fl.query(where=sql, returnIDsOnly=True)
if 'objectIds' in qRes:
oids = qRes['objectIds']
if len(oids)> 0 :
print ("%s features to be deleted" % len(oids))
results = fl.deleteFeatures(where=sql)
if 'deleteResults' in results:
totalDeleted += len(results['deleteResults'])
return {'success':True,'message': "%s deleted" % totalDeleted}
else:
return results
return {'success':True,'message': "%s deleted" % totalDeleted}
else:
print (qRes)
else:
results = fl.deleteFeatures(where=sql)
if results is not None:
if 'deleteResults' in results:
return {'success':True,'message': totalDeleted + len(results['deleteResults'])}
else:
return results
except:
line, filename, synerror = trace()
raise common.ArcRestHelperError({
"function": "DeleteFeaturesFromFeatureLayer",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
fl = None
del fl
gc.collect() | python | def DeleteFeaturesFromFeatureLayer(self, url, sql, chunksize=0):
"""Removes features from a hosted feature service layer by SQL query.
Args:
url (str): The URL of the feature service layer.
sql (str): The SQL query to apply against the feature service.
Those features that satisfy the query will be deleted.
chunksize (int): The maximum amount of features to remove at a time. Defaults to 0.
Returns:
The result from :py:func:`arcrest.agol.services.FeatureLayer.deleteFeatures`.
Notes:
If you want to delete all features, it is suggested to use the SQL query ``"1=1"``.
"""
fl = None
try:
fl = FeatureLayer(
url=url,
securityHandler=self._securityHandler)
totalDeleted = 0
if chunksize > 0:
qRes = fl.query(where=sql, returnIDsOnly=True)
if 'error' in qRes:
print (qRes)
return qRes
elif 'objectIds' in qRes:
oids = qRes['objectIds']
total = len(oids)
if total == 0:
return {'success':True,'message': "No features matched the query"}
i = 0
print ("%s features to be deleted" % total)
while(i <= len(oids)):
oidsDelete = ','.join(str(e) for e in oids[i:i+chunksize])
if oidsDelete == '':
continue
else:
results = fl.deleteFeatures(objectIds=oidsDelete)
if 'deleteResults' in results:
totalDeleted += len(results['deleteResults'])
print ("%s%% Completed: %s/%s " % (int(totalDeleted / float(total) *100), totalDeleted, total))
i += chunksize
else:
print (results)
return {'success':True,'message': "%s deleted" % totalDeleted}
qRes = fl.query(where=sql, returnIDsOnly=True)
if 'objectIds' in qRes:
oids = qRes['objectIds']
if len(oids)> 0 :
print ("%s features to be deleted" % len(oids))
results = fl.deleteFeatures(where=sql)
if 'deleteResults' in results:
totalDeleted += len(results['deleteResults'])
return {'success':True,'message': "%s deleted" % totalDeleted}
else:
return results
return {'success':True,'message': "%s deleted" % totalDeleted}
else:
print (qRes)
else:
results = fl.deleteFeatures(where=sql)
if results is not None:
if 'deleteResults' in results:
return {'success':True,'message': totalDeleted + len(results['deleteResults'])}
else:
return results
except:
line, filename, synerror = trace()
raise common.ArcRestHelperError({
"function": "DeleteFeaturesFromFeatureLayer",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
fl = None
del fl
gc.collect() | [
"def",
"DeleteFeaturesFromFeatureLayer",
"(",
"self",
",",
"url",
",",
"sql",
",",
"chunksize",
"=",
"0",
")",
":",
"fl",
"=",
"None",
"try",
":",
"fl",
"=",
"FeatureLayer",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
")",
"totalDeleted",
"=",
"0",
"if",
"chunksize",
">",
"0",
":",
"qRes",
"=",
"fl",
".",
"query",
"(",
"where",
"=",
"sql",
",",
"returnIDsOnly",
"=",
"True",
")",
"if",
"'error'",
"in",
"qRes",
":",
"print",
"(",
"qRes",
")",
"return",
"qRes",
"elif",
"'objectIds'",
"in",
"qRes",
":",
"oids",
"=",
"qRes",
"[",
"'objectIds'",
"]",
"total",
"=",
"len",
"(",
"oids",
")",
"if",
"total",
"==",
"0",
":",
"return",
"{",
"'success'",
":",
"True",
",",
"'message'",
":",
"\"No features matched the query\"",
"}",
"i",
"=",
"0",
"print",
"(",
"\"%s features to be deleted\"",
"%",
"total",
")",
"while",
"(",
"i",
"<=",
"len",
"(",
"oids",
")",
")",
":",
"oidsDelete",
"=",
"','",
".",
"join",
"(",
"str",
"(",
"e",
")",
"for",
"e",
"in",
"oids",
"[",
"i",
":",
"i",
"+",
"chunksize",
"]",
")",
"if",
"oidsDelete",
"==",
"''",
":",
"continue",
"else",
":",
"results",
"=",
"fl",
".",
"deleteFeatures",
"(",
"objectIds",
"=",
"oidsDelete",
")",
"if",
"'deleteResults'",
"in",
"results",
":",
"totalDeleted",
"+=",
"len",
"(",
"results",
"[",
"'deleteResults'",
"]",
")",
"print",
"(",
"\"%s%% Completed: %s/%s \"",
"%",
"(",
"int",
"(",
"totalDeleted",
"/",
"float",
"(",
"total",
")",
"*",
"100",
")",
",",
"totalDeleted",
",",
"total",
")",
")",
"i",
"+=",
"chunksize",
"else",
":",
"print",
"(",
"results",
")",
"return",
"{",
"'success'",
":",
"True",
",",
"'message'",
":",
"\"%s deleted\"",
"%",
"totalDeleted",
"}",
"qRes",
"=",
"fl",
".",
"query",
"(",
"where",
"=",
"sql",
",",
"returnIDsOnly",
"=",
"True",
")",
"if",
"'objectIds'",
"in",
"qRes",
":",
"oids",
"=",
"qRes",
"[",
"'objectIds'",
"]",
"if",
"len",
"(",
"oids",
")",
">",
"0",
":",
"print",
"(",
"\"%s features to be deleted\"",
"%",
"len",
"(",
"oids",
")",
")",
"results",
"=",
"fl",
".",
"deleteFeatures",
"(",
"where",
"=",
"sql",
")",
"if",
"'deleteResults'",
"in",
"results",
":",
"totalDeleted",
"+=",
"len",
"(",
"results",
"[",
"'deleteResults'",
"]",
")",
"return",
"{",
"'success'",
":",
"True",
",",
"'message'",
":",
"\"%s deleted\"",
"%",
"totalDeleted",
"}",
"else",
":",
"return",
"results",
"return",
"{",
"'success'",
":",
"True",
",",
"'message'",
":",
"\"%s deleted\"",
"%",
"totalDeleted",
"}",
"else",
":",
"print",
"(",
"qRes",
")",
"else",
":",
"results",
"=",
"fl",
".",
"deleteFeatures",
"(",
"where",
"=",
"sql",
")",
"if",
"results",
"is",
"not",
"None",
":",
"if",
"'deleteResults'",
"in",
"results",
":",
"return",
"{",
"'success'",
":",
"True",
",",
"'message'",
":",
"totalDeleted",
"+",
"len",
"(",
"results",
"[",
"'deleteResults'",
"]",
")",
"}",
"else",
":",
"return",
"results",
"except",
":",
"line",
",",
"filename",
",",
"synerror",
"=",
"trace",
"(",
")",
"raise",
"common",
".",
"ArcRestHelperError",
"(",
"{",
"\"function\"",
":",
"\"DeleteFeaturesFromFeatureLayer\"",
",",
"\"line\"",
":",
"line",
",",
"\"filename\"",
":",
"filename",
",",
"\"synerror\"",
":",
"synerror",
",",
"}",
")",
"finally",
":",
"fl",
"=",
"None",
"del",
"fl",
"gc",
".",
"collect",
"(",
")"
] | Removes features from a hosted feature service layer by SQL query.
Args:
url (str): The URL of the feature service layer.
sql (str): The SQL query to apply against the feature service.
Those features that satisfy the query will be deleted.
chunksize (int): The maximum amount of features to remove at a time. Defaults to 0.
Returns:
The result from :py:func:`arcrest.agol.services.FeatureLayer.deleteFeatures`.
Notes:
If you want to delete all features, it is suggested to use the SQL query ``"1=1"``. | [
"Removes",
"features",
"from",
"a",
"hosted",
"feature",
"service",
"layer",
"by",
"SQL",
"query",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/featureservicetools.py#L570-L648 | train |
Esri/ArcREST | src/arcresthelper/featureservicetools.py | featureservicetools.QueryAllFeatures | def QueryAllFeatures(self, url=None,
where="1=1",
out_fields="*",
timeFilter=None,
geometryFilter=None,
returnFeatureClass=False,
out_fc=None,
outSR=None,
chunksize=1000,
printIndent=""):
"""Performs an SQL query against a hosted feature service layer
and returns all features regardless of service limit.
Args:
url (str): The URL of the feature service layer.
where - the selection sql statement
out_fields - the attribute fields to return
timeFilter - a TimeFilter object where either the start time
or start and end time are defined to limit the
search results for a given time. The values in
the timeFilter should be as UTC timestampes in
milliseconds. No checking occurs to see if they
are in the right format.
geometryFilter - a GeometryFilter object to parse down a given
query by another spatial dataset.
returnFeatureClass - Default False. If true, query will be
returned as feature class
chunksize (int): The maximum amount of features to query at a time. Defaults to 1000.
out_fc - only valid if returnFeatureClass is set to True.
Output location of query.
Output:
A list of Feature Objects (default) or a path to the output featureclass if
returnFeatureClass is set to True.
"""
if (url is None):
return
fl = None
try:
fl = FeatureLayer(url=url, securityHandler=self._securityHandler)
qRes = fl.query(where=where,
returnIDsOnly=True,
timeFilter=timeFilter,
geometryFilter=geometryFilter)
if 'error' in qRes:
print (printIndent + qRes)
return []
elif 'objectIds' in qRes:
oids = qRes['objectIds']
total = len(oids)
if total == 0:
return fl.query(where=where,
returnGeometry=True,
out_fields=out_fields,
timeFilter=timeFilter,
geometryFilter=geometryFilter,
outSR=outSR)
print (printIndent + "%s features to be downloaded" % total)
chunksize = min(chunksize, fl.maxRecordCount)
combinedResults = None
totalQueried = 0
for chunk in chunklist(l=oids, n=chunksize):
oidsQuery = ",".join(map(str, chunk))
if not oidsQuery:
continue
else:
results = fl.query(objectIds=oidsQuery,
returnGeometry=True,
out_fields=out_fields,
timeFilter=timeFilter,
geometryFilter=geometryFilter,
outSR=outSR)
if isinstance(results,FeatureSet):
if combinedResults is None:
combinedResults = results
else:
for feature in results.features:
combinedResults.features.append(feature)
totalQueried += len(results.features)
print(printIndent + "{:.0%} Completed: {}/{}".format(totalQueried / float(total), totalQueried, total))
else:
print (printIndent + results)
if returnFeatureClass == True:
return combinedResults.save(*os.path.split(out_fc))
else:
return combinedResults
else:
print (printIndent + qRes)
except:
line, filename, synerror = trace()
raise common.ArcRestHelperError({
"function": "QueryAllFeatures",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
fl = None
del fl
gc.collect() | python | def QueryAllFeatures(self, url=None,
where="1=1",
out_fields="*",
timeFilter=None,
geometryFilter=None,
returnFeatureClass=False,
out_fc=None,
outSR=None,
chunksize=1000,
printIndent=""):
"""Performs an SQL query against a hosted feature service layer
and returns all features regardless of service limit.
Args:
url (str): The URL of the feature service layer.
where - the selection sql statement
out_fields - the attribute fields to return
timeFilter - a TimeFilter object where either the start time
or start and end time are defined to limit the
search results for a given time. The values in
the timeFilter should be as UTC timestampes in
milliseconds. No checking occurs to see if they
are in the right format.
geometryFilter - a GeometryFilter object to parse down a given
query by another spatial dataset.
returnFeatureClass - Default False. If true, query will be
returned as feature class
chunksize (int): The maximum amount of features to query at a time. Defaults to 1000.
out_fc - only valid if returnFeatureClass is set to True.
Output location of query.
Output:
A list of Feature Objects (default) or a path to the output featureclass if
returnFeatureClass is set to True.
"""
if (url is None):
return
fl = None
try:
fl = FeatureLayer(url=url, securityHandler=self._securityHandler)
qRes = fl.query(where=where,
returnIDsOnly=True,
timeFilter=timeFilter,
geometryFilter=geometryFilter)
if 'error' in qRes:
print (printIndent + qRes)
return []
elif 'objectIds' in qRes:
oids = qRes['objectIds']
total = len(oids)
if total == 0:
return fl.query(where=where,
returnGeometry=True,
out_fields=out_fields,
timeFilter=timeFilter,
geometryFilter=geometryFilter,
outSR=outSR)
print (printIndent + "%s features to be downloaded" % total)
chunksize = min(chunksize, fl.maxRecordCount)
combinedResults = None
totalQueried = 0
for chunk in chunklist(l=oids, n=chunksize):
oidsQuery = ",".join(map(str, chunk))
if not oidsQuery:
continue
else:
results = fl.query(objectIds=oidsQuery,
returnGeometry=True,
out_fields=out_fields,
timeFilter=timeFilter,
geometryFilter=geometryFilter,
outSR=outSR)
if isinstance(results,FeatureSet):
if combinedResults is None:
combinedResults = results
else:
for feature in results.features:
combinedResults.features.append(feature)
totalQueried += len(results.features)
print(printIndent + "{:.0%} Completed: {}/{}".format(totalQueried / float(total), totalQueried, total))
else:
print (printIndent + results)
if returnFeatureClass == True:
return combinedResults.save(*os.path.split(out_fc))
else:
return combinedResults
else:
print (printIndent + qRes)
except:
line, filename, synerror = trace()
raise common.ArcRestHelperError({
"function": "QueryAllFeatures",
"line": line,
"filename": filename,
"synerror": synerror,
}
)
finally:
fl = None
del fl
gc.collect() | [
"def",
"QueryAllFeatures",
"(",
"self",
",",
"url",
"=",
"None",
",",
"where",
"=",
"\"1=1\"",
",",
"out_fields",
"=",
"\"*\"",
",",
"timeFilter",
"=",
"None",
",",
"geometryFilter",
"=",
"None",
",",
"returnFeatureClass",
"=",
"False",
",",
"out_fc",
"=",
"None",
",",
"outSR",
"=",
"None",
",",
"chunksize",
"=",
"1000",
",",
"printIndent",
"=",
"\"\"",
")",
":",
"if",
"(",
"url",
"is",
"None",
")",
":",
"return",
"fl",
"=",
"None",
"try",
":",
"fl",
"=",
"FeatureLayer",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
")",
"qRes",
"=",
"fl",
".",
"query",
"(",
"where",
"=",
"where",
",",
"returnIDsOnly",
"=",
"True",
",",
"timeFilter",
"=",
"timeFilter",
",",
"geometryFilter",
"=",
"geometryFilter",
")",
"if",
"'error'",
"in",
"qRes",
":",
"print",
"(",
"printIndent",
"+",
"qRes",
")",
"return",
"[",
"]",
"elif",
"'objectIds'",
"in",
"qRes",
":",
"oids",
"=",
"qRes",
"[",
"'objectIds'",
"]",
"total",
"=",
"len",
"(",
"oids",
")",
"if",
"total",
"==",
"0",
":",
"return",
"fl",
".",
"query",
"(",
"where",
"=",
"where",
",",
"returnGeometry",
"=",
"True",
",",
"out_fields",
"=",
"out_fields",
",",
"timeFilter",
"=",
"timeFilter",
",",
"geometryFilter",
"=",
"geometryFilter",
",",
"outSR",
"=",
"outSR",
")",
"print",
"(",
"printIndent",
"+",
"\"%s features to be downloaded\"",
"%",
"total",
")",
"chunksize",
"=",
"min",
"(",
"chunksize",
",",
"fl",
".",
"maxRecordCount",
")",
"combinedResults",
"=",
"None",
"totalQueried",
"=",
"0",
"for",
"chunk",
"in",
"chunklist",
"(",
"l",
"=",
"oids",
",",
"n",
"=",
"chunksize",
")",
":",
"oidsQuery",
"=",
"\",\"",
".",
"join",
"(",
"map",
"(",
"str",
",",
"chunk",
")",
")",
"if",
"not",
"oidsQuery",
":",
"continue",
"else",
":",
"results",
"=",
"fl",
".",
"query",
"(",
"objectIds",
"=",
"oidsQuery",
",",
"returnGeometry",
"=",
"True",
",",
"out_fields",
"=",
"out_fields",
",",
"timeFilter",
"=",
"timeFilter",
",",
"geometryFilter",
"=",
"geometryFilter",
",",
"outSR",
"=",
"outSR",
")",
"if",
"isinstance",
"(",
"results",
",",
"FeatureSet",
")",
":",
"if",
"combinedResults",
"is",
"None",
":",
"combinedResults",
"=",
"results",
"else",
":",
"for",
"feature",
"in",
"results",
".",
"features",
":",
"combinedResults",
".",
"features",
".",
"append",
"(",
"feature",
")",
"totalQueried",
"+=",
"len",
"(",
"results",
".",
"features",
")",
"print",
"(",
"printIndent",
"+",
"\"{:.0%} Completed: {}/{}\"",
".",
"format",
"(",
"totalQueried",
"/",
"float",
"(",
"total",
")",
",",
"totalQueried",
",",
"total",
")",
")",
"else",
":",
"print",
"(",
"printIndent",
"+",
"results",
")",
"if",
"returnFeatureClass",
"==",
"True",
":",
"return",
"combinedResults",
".",
"save",
"(",
"*",
"os",
".",
"path",
".",
"split",
"(",
"out_fc",
")",
")",
"else",
":",
"return",
"combinedResults",
"else",
":",
"print",
"(",
"printIndent",
"+",
"qRes",
")",
"except",
":",
"line",
",",
"filename",
",",
"synerror",
"=",
"trace",
"(",
")",
"raise",
"common",
".",
"ArcRestHelperError",
"(",
"{",
"\"function\"",
":",
"\"QueryAllFeatures\"",
",",
"\"line\"",
":",
"line",
",",
"\"filename\"",
":",
"filename",
",",
"\"synerror\"",
":",
"synerror",
",",
"}",
")",
"finally",
":",
"fl",
"=",
"None",
"del",
"fl",
"gc",
".",
"collect",
"(",
")"
] | Performs an SQL query against a hosted feature service layer
and returns all features regardless of service limit.
Args:
url (str): The URL of the feature service layer.
where - the selection sql statement
out_fields - the attribute fields to return
timeFilter - a TimeFilter object where either the start time
or start and end time are defined to limit the
search results for a given time. The values in
the timeFilter should be as UTC timestampes in
milliseconds. No checking occurs to see if they
are in the right format.
geometryFilter - a GeometryFilter object to parse down a given
query by another spatial dataset.
returnFeatureClass - Default False. If true, query will be
returned as feature class
chunksize (int): The maximum amount of features to query at a time. Defaults to 1000.
out_fc - only valid if returnFeatureClass is set to True.
Output location of query.
Output:
A list of Feature Objects (default) or a path to the output featureclass if
returnFeatureClass is set to True. | [
"Performs",
"an",
"SQL",
"query",
"against",
"a",
"hosted",
"feature",
"service",
"layer",
"and",
"returns",
"all",
"features",
"regardless",
"of",
"service",
"limit",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/featureservicetools.py#L650-L756 | train |
Esri/ArcREST | src/arcrest/cmp/community.py | CommunityMapsProgram.contributionStatus | def contributionStatus(self):
"""gets the contribution status of a user"""
import time
url = "%s/contributors/%s/activeContribution" % (self.root, quote(self.contributorUID))
params = {
"agolUserToken" : self._agolSH.token,
"f" : "json"
}
res = self._get(url=url,
param_dict=params,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
if'Status' in res and \
res['Status'] == 'start':
return True
return False | python | def contributionStatus(self):
"""gets the contribution status of a user"""
import time
url = "%s/contributors/%s/activeContribution" % (self.root, quote(self.contributorUID))
params = {
"agolUserToken" : self._agolSH.token,
"f" : "json"
}
res = self._get(url=url,
param_dict=params,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
if'Status' in res and \
res['Status'] == 'start':
return True
return False | [
"def",
"contributionStatus",
"(",
"self",
")",
":",
"import",
"time",
"url",
"=",
"\"%s/contributors/%s/activeContribution\"",
"%",
"(",
"self",
".",
"root",
",",
"quote",
"(",
"self",
".",
"contributorUID",
")",
")",
"params",
"=",
"{",
"\"agolUserToken\"",
":",
"self",
".",
"_agolSH",
".",
"token",
",",
"\"f\"",
":",
"\"json\"",
"}",
"res",
"=",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"if",
"'Status'",
"in",
"res",
"and",
"res",
"[",
"'Status'",
"]",
"==",
"'start'",
":",
"return",
"True",
"return",
"False"
] | gets the contribution status of a user | [
"gets",
"the",
"contribution",
"status",
"of",
"a",
"user"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/cmp/community.py#L62-L77 | train |
Esri/ArcREST | src/arcrest/cmp/community.py | CommunityMapsProgram.user | def user(self):
"""gets the user properties"""
if self._user is None:
url = "%s/users/%s" % (self.root, self._username)
self._user = CMPUser(url=url,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url,
initialize=False)
return self._user | python | def user(self):
"""gets the user properties"""
if self._user is None:
url = "%s/users/%s" % (self.root, self._username)
self._user = CMPUser(url=url,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url,
initialize=False)
return self._user | [
"def",
"user",
"(",
"self",
")",
":",
"if",
"self",
".",
"_user",
"is",
"None",
":",
"url",
"=",
"\"%s/users/%s\"",
"%",
"(",
"self",
".",
"root",
",",
"self",
".",
"_username",
")",
"self",
".",
"_user",
"=",
"CMPUser",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"initialize",
"=",
"False",
")",
"return",
"self",
".",
"_user"
] | gets the user properties | [
"gets",
"the",
"user",
"properties"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/cmp/community.py#L84-L93 | train |
Esri/ArcREST | src/arcrest/cmp/community.py | CommunityMapsProgram.metadataContributer | def metadataContributer(self):
"""gets the metadata featurelayer object"""
if self._metaFL is None:
fl = FeatureService(url=self._metadataURL,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
self._metaFS = fl
return self._metaFS | python | def metadataContributer(self):
"""gets the metadata featurelayer object"""
if self._metaFL is None:
fl = FeatureService(url=self._metadataURL,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port)
self._metaFS = fl
return self._metaFS | [
"def",
"metadataContributer",
"(",
"self",
")",
":",
"if",
"self",
".",
"_metaFL",
"is",
"None",
":",
"fl",
"=",
"FeatureService",
"(",
"url",
"=",
"self",
".",
"_metadataURL",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")",
"self",
".",
"_metaFS",
"=",
"fl",
"return",
"self",
".",
"_metaFS"
] | gets the metadata featurelayer object | [
"gets",
"the",
"metadata",
"featurelayer",
"object"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/cmp/community.py#L108-L115 | train |
Esri/ArcREST | src/arcrest/common/general.py | Feature.set_value | def set_value(self, field_name, value):
""" sets an attribute value for a given field name """
if field_name in self.fields:
if not value is None:
self._dict['attributes'][field_name] = _unicode_convert(value)
else:
pass
elif field_name.upper() in ['SHAPE', 'SHAPE@', "GEOMETRY"]:
if isinstance(value, dict):
if 'geometry' in value:
self._dict['geometry'] = value['geometry']
elif any(k in value.keys() for k in ['x','y','points','paths','rings', 'spatialReference']):
self._dict['geometry'] = value
elif isinstance(value, AbstractGeometry):
self._dict['geometry'] = value.asDictionary
elif arcpyFound:
if isinstance(value, arcpy.Geometry) and \
value.type == self.geometryType:
self._dict['geometry']=json.loads(value.JSON)
self._geom = None
self._geom = self.geometry
else:
return False
self._json = json.dumps(self._dict, default=_date_handler)
return True | python | def set_value(self, field_name, value):
""" sets an attribute value for a given field name """
if field_name in self.fields:
if not value is None:
self._dict['attributes'][field_name] = _unicode_convert(value)
else:
pass
elif field_name.upper() in ['SHAPE', 'SHAPE@', "GEOMETRY"]:
if isinstance(value, dict):
if 'geometry' in value:
self._dict['geometry'] = value['geometry']
elif any(k in value.keys() for k in ['x','y','points','paths','rings', 'spatialReference']):
self._dict['geometry'] = value
elif isinstance(value, AbstractGeometry):
self._dict['geometry'] = value.asDictionary
elif arcpyFound:
if isinstance(value, arcpy.Geometry) and \
value.type == self.geometryType:
self._dict['geometry']=json.loads(value.JSON)
self._geom = None
self._geom = self.geometry
else:
return False
self._json = json.dumps(self._dict, default=_date_handler)
return True | [
"def",
"set_value",
"(",
"self",
",",
"field_name",
",",
"value",
")",
":",
"if",
"field_name",
"in",
"self",
".",
"fields",
":",
"if",
"not",
"value",
"is",
"None",
":",
"self",
".",
"_dict",
"[",
"'attributes'",
"]",
"[",
"field_name",
"]",
"=",
"_unicode_convert",
"(",
"value",
")",
"else",
":",
"pass",
"elif",
"field_name",
".",
"upper",
"(",
")",
"in",
"[",
"'SHAPE'",
",",
"'SHAPE@'",
",",
"\"GEOMETRY\"",
"]",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"if",
"'geometry'",
"in",
"value",
":",
"self",
".",
"_dict",
"[",
"'geometry'",
"]",
"=",
"value",
"[",
"'geometry'",
"]",
"elif",
"any",
"(",
"k",
"in",
"value",
".",
"keys",
"(",
")",
"for",
"k",
"in",
"[",
"'x'",
",",
"'y'",
",",
"'points'",
",",
"'paths'",
",",
"'rings'",
",",
"'spatialReference'",
"]",
")",
":",
"self",
".",
"_dict",
"[",
"'geometry'",
"]",
"=",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"AbstractGeometry",
")",
":",
"self",
".",
"_dict",
"[",
"'geometry'",
"]",
"=",
"value",
".",
"asDictionary",
"elif",
"arcpyFound",
":",
"if",
"isinstance",
"(",
"value",
",",
"arcpy",
".",
"Geometry",
")",
"and",
"value",
".",
"type",
"==",
"self",
".",
"geometryType",
":",
"self",
".",
"_dict",
"[",
"'geometry'",
"]",
"=",
"json",
".",
"loads",
"(",
"value",
".",
"JSON",
")",
"self",
".",
"_geom",
"=",
"None",
"self",
".",
"_geom",
"=",
"self",
".",
"geometry",
"else",
":",
"return",
"False",
"self",
".",
"_json",
"=",
"json",
".",
"dumps",
"(",
"self",
".",
"_dict",
",",
"default",
"=",
"_date_handler",
")",
"return",
"True"
] | sets an attribute value for a given field name | [
"sets",
"an",
"attribute",
"value",
"for",
"a",
"given",
"field",
"name"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L136-L160 | train |
Esri/ArcREST | src/arcrest/common/general.py | Feature.get_value | def get_value(self, field_name):
""" returns a value for a given field name """
if field_name in self.fields:
return self._dict['attributes'][field_name]
elif field_name.upper() in ['SHAPE', 'SHAPE@', "GEOMETRY"]:
return self._dict['geometry']
return None | python | def get_value(self, field_name):
""" returns a value for a given field name """
if field_name in self.fields:
return self._dict['attributes'][field_name]
elif field_name.upper() in ['SHAPE', 'SHAPE@', "GEOMETRY"]:
return self._dict['geometry']
return None | [
"def",
"get_value",
"(",
"self",
",",
"field_name",
")",
":",
"if",
"field_name",
"in",
"self",
".",
"fields",
":",
"return",
"self",
".",
"_dict",
"[",
"'attributes'",
"]",
"[",
"field_name",
"]",
"elif",
"field_name",
".",
"upper",
"(",
")",
"in",
"[",
"'SHAPE'",
",",
"'SHAPE@'",
",",
"\"GEOMETRY\"",
"]",
":",
"return",
"self",
".",
"_dict",
"[",
"'geometry'",
"]",
"return",
"None"
] | returns a value for a given field name | [
"returns",
"a",
"value",
"for",
"a",
"given",
"field",
"name"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L162-L168 | train |
Esri/ArcREST | src/arcrest/common/general.py | Feature.asDictionary | def asDictionary(self):
"""returns the feature as a dictionary"""
feat_dict = {}
if self._geom is not None:
if 'feature' in self._dict:
feat_dict['geometry'] = self._dict['feature']['geometry']
elif 'geometry' in self._dict:
feat_dict['geometry'] = self._dict['geometry']
if 'feature' in self._dict:
feat_dict['attributes'] = self._dict['feature']['attributes']
else:
feat_dict['attributes'] = self._dict['attributes']
return self._dict | python | def asDictionary(self):
"""returns the feature as a dictionary"""
feat_dict = {}
if self._geom is not None:
if 'feature' in self._dict:
feat_dict['geometry'] = self._dict['feature']['geometry']
elif 'geometry' in self._dict:
feat_dict['geometry'] = self._dict['geometry']
if 'feature' in self._dict:
feat_dict['attributes'] = self._dict['feature']['attributes']
else:
feat_dict['attributes'] = self._dict['attributes']
return self._dict | [
"def",
"asDictionary",
"(",
"self",
")",
":",
"feat_dict",
"=",
"{",
"}",
"if",
"self",
".",
"_geom",
"is",
"not",
"None",
":",
"if",
"'feature'",
"in",
"self",
".",
"_dict",
":",
"feat_dict",
"[",
"'geometry'",
"]",
"=",
"self",
".",
"_dict",
"[",
"'feature'",
"]",
"[",
"'geometry'",
"]",
"elif",
"'geometry'",
"in",
"self",
".",
"_dict",
":",
"feat_dict",
"[",
"'geometry'",
"]",
"=",
"self",
".",
"_dict",
"[",
"'geometry'",
"]",
"if",
"'feature'",
"in",
"self",
".",
"_dict",
":",
"feat_dict",
"[",
"'attributes'",
"]",
"=",
"self",
".",
"_dict",
"[",
"'feature'",
"]",
"[",
"'attributes'",
"]",
"else",
":",
"feat_dict",
"[",
"'attributes'",
"]",
"=",
"self",
".",
"_dict",
"[",
"'attributes'",
"]",
"return",
"self",
".",
"_dict"
] | returns the feature as a dictionary | [
"returns",
"the",
"feature",
"as",
"a",
"dictionary"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L171-L183 | train |
Esri/ArcREST | src/arcrest/common/general.py | Feature.geometry | def geometry(self):
"""returns the feature geometry"""
if arcpyFound:
if self._geom is None:
if 'feature' in self._dict:
self._geom = arcpy.AsShape(self._dict['feature']['geometry'], esri_json=True)
elif 'geometry' in self._dict:
self._geom = arcpy.AsShape(self._dict['geometry'], esri_json=True)
return self._geom
return None | python | def geometry(self):
"""returns the feature geometry"""
if arcpyFound:
if self._geom is None:
if 'feature' in self._dict:
self._geom = arcpy.AsShape(self._dict['feature']['geometry'], esri_json=True)
elif 'geometry' in self._dict:
self._geom = arcpy.AsShape(self._dict['geometry'], esri_json=True)
return self._geom
return None | [
"def",
"geometry",
"(",
"self",
")",
":",
"if",
"arcpyFound",
":",
"if",
"self",
".",
"_geom",
"is",
"None",
":",
"if",
"'feature'",
"in",
"self",
".",
"_dict",
":",
"self",
".",
"_geom",
"=",
"arcpy",
".",
"AsShape",
"(",
"self",
".",
"_dict",
"[",
"'feature'",
"]",
"[",
"'geometry'",
"]",
",",
"esri_json",
"=",
"True",
")",
"elif",
"'geometry'",
"in",
"self",
".",
"_dict",
":",
"self",
".",
"_geom",
"=",
"arcpy",
".",
"AsShape",
"(",
"self",
".",
"_dict",
"[",
"'geometry'",
"]",
",",
"esri_json",
"=",
"True",
")",
"return",
"self",
".",
"_geom",
"return",
"None"
] | returns the feature geometry | [
"returns",
"the",
"feature",
"geometry"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L204-L213 | train |
Esri/ArcREST | src/arcrest/common/general.py | Feature.fields | def fields(self):
""" returns a list of feature fields """
if 'feature' in self._dict:
self._attributes = self._dict['feature']['attributes']
else:
self._attributes = self._dict['attributes']
return self._attributes.keys() | python | def fields(self):
""" returns a list of feature fields """
if 'feature' in self._dict:
self._attributes = self._dict['feature']['attributes']
else:
self._attributes = self._dict['attributes']
return self._attributes.keys() | [
"def",
"fields",
"(",
"self",
")",
":",
"if",
"'feature'",
"in",
"self",
".",
"_dict",
":",
"self",
".",
"_attributes",
"=",
"self",
".",
"_dict",
"[",
"'feature'",
"]",
"[",
"'attributes'",
"]",
"else",
":",
"self",
".",
"_attributes",
"=",
"self",
".",
"_dict",
"[",
"'attributes'",
"]",
"return",
"self",
".",
"_attributes",
".",
"keys",
"(",
")"
] | returns a list of feature fields | [
"returns",
"a",
"list",
"of",
"feature",
"fields"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L228-L234 | train |
Esri/ArcREST | src/arcrest/common/general.py | Feature.geometryType | def geometryType(self):
""" returns the feature's geometry type """
if self._geomType is None:
if self.geometry is not None:
self._geomType = self.geometry.type
else:
self._geomType = "Table"
return self._geomType | python | def geometryType(self):
""" returns the feature's geometry type """
if self._geomType is None:
if self.geometry is not None:
self._geomType = self.geometry.type
else:
self._geomType = "Table"
return self._geomType | [
"def",
"geometryType",
"(",
"self",
")",
":",
"if",
"self",
".",
"_geomType",
"is",
"None",
":",
"if",
"self",
".",
"geometry",
"is",
"not",
"None",
":",
"self",
".",
"_geomType",
"=",
"self",
".",
"geometry",
".",
"type",
"else",
":",
"self",
".",
"_geomType",
"=",
"\"Table\"",
"return",
"self",
".",
"_geomType"
] | returns the feature's geometry type | [
"returns",
"the",
"feature",
"s",
"geometry",
"type"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L237-L244 | train |
Esri/ArcREST | src/arcrest/common/general.py | MosaicRuleObject.value | def value(self):
"""
gets the mosaic rule object as a dictionary
"""
if self.mosaicMethod == "esriMosaicNone" or\
self.mosaicMethod == "esriMosaicCenter" or \
self.mosaicMethod == "esriMosaicNorthwest" or \
self.mosaicMethod == "esriMosaicNadir":
return {
"mosaicMethod" : "esriMosaicNone",
"where" : self._where,
"ascending" : self._ascending,
"fids" : self.fids,
"mosaicOperation" : self._mosaicOperation
}
elif self.mosaicMethod == "esriMosaicViewpoint":
return {
"mosaicMethod" : "esriMosaicViewpoint",
"viewpoint" : self._viewpoint.asDictionary,
"where" : self._where,
"ascending" : self._ascending,
"fids" : self._fids,
"mosaicOperation" : self._mosaicOperation
}
elif self.mosaicMethod == "esriMosaicAttribute":
return {
"mosaicMethod" : "esriMosaicAttribute",
"sortField" : self._sortField,
"sortValue" : self._sortValue,
"ascending" : self._ascending,
"where" : self._where,
"fids" : self._fids,
"mosaicOperation" : self._mosaicOperation
}
elif self.mosaicMethod == "esriMosaicLockRaster":
return {
"mosaicMethod" : "esriMosaicLockRaster",
"lockRasterIds" : self._localRasterIds,
"where" : self._where,
"ascending" : self._ascending,
"fids" : self._fids,
"mosaicOperation" : self._mosaicOperation
}
elif self.mosaicMethod == "esriMosaicSeamline":
return {
"mosaicMethod" : "esriMosaicSeamline",
"where" : self._where,
"fids" : self._fids,
"mosaicOperation" : self._mosaicOperation
}
else:
raise AttributeError("Invalid Mosaic Method") | python | def value(self):
"""
gets the mosaic rule object as a dictionary
"""
if self.mosaicMethod == "esriMosaicNone" or\
self.mosaicMethod == "esriMosaicCenter" or \
self.mosaicMethod == "esriMosaicNorthwest" or \
self.mosaicMethod == "esriMosaicNadir":
return {
"mosaicMethod" : "esriMosaicNone",
"where" : self._where,
"ascending" : self._ascending,
"fids" : self.fids,
"mosaicOperation" : self._mosaicOperation
}
elif self.mosaicMethod == "esriMosaicViewpoint":
return {
"mosaicMethod" : "esriMosaicViewpoint",
"viewpoint" : self._viewpoint.asDictionary,
"where" : self._where,
"ascending" : self._ascending,
"fids" : self._fids,
"mosaicOperation" : self._mosaicOperation
}
elif self.mosaicMethod == "esriMosaicAttribute":
return {
"mosaicMethod" : "esriMosaicAttribute",
"sortField" : self._sortField,
"sortValue" : self._sortValue,
"ascending" : self._ascending,
"where" : self._where,
"fids" : self._fids,
"mosaicOperation" : self._mosaicOperation
}
elif self.mosaicMethod == "esriMosaicLockRaster":
return {
"mosaicMethod" : "esriMosaicLockRaster",
"lockRasterIds" : self._localRasterIds,
"where" : self._where,
"ascending" : self._ascending,
"fids" : self._fids,
"mosaicOperation" : self._mosaicOperation
}
elif self.mosaicMethod == "esriMosaicSeamline":
return {
"mosaicMethod" : "esriMosaicSeamline",
"where" : self._where,
"fids" : self._fids,
"mosaicOperation" : self._mosaicOperation
}
else:
raise AttributeError("Invalid Mosaic Method") | [
"def",
"value",
"(",
"self",
")",
":",
"if",
"self",
".",
"mosaicMethod",
"==",
"\"esriMosaicNone\"",
"or",
"self",
".",
"mosaicMethod",
"==",
"\"esriMosaicCenter\"",
"or",
"self",
".",
"mosaicMethod",
"==",
"\"esriMosaicNorthwest\"",
"or",
"self",
".",
"mosaicMethod",
"==",
"\"esriMosaicNadir\"",
":",
"return",
"{",
"\"mosaicMethod\"",
":",
"\"esriMosaicNone\"",
",",
"\"where\"",
":",
"self",
".",
"_where",
",",
"\"ascending\"",
":",
"self",
".",
"_ascending",
",",
"\"fids\"",
":",
"self",
".",
"fids",
",",
"\"mosaicOperation\"",
":",
"self",
".",
"_mosaicOperation",
"}",
"elif",
"self",
".",
"mosaicMethod",
"==",
"\"esriMosaicViewpoint\"",
":",
"return",
"{",
"\"mosaicMethod\"",
":",
"\"esriMosaicViewpoint\"",
",",
"\"viewpoint\"",
":",
"self",
".",
"_viewpoint",
".",
"asDictionary",
",",
"\"where\"",
":",
"self",
".",
"_where",
",",
"\"ascending\"",
":",
"self",
".",
"_ascending",
",",
"\"fids\"",
":",
"self",
".",
"_fids",
",",
"\"mosaicOperation\"",
":",
"self",
".",
"_mosaicOperation",
"}",
"elif",
"self",
".",
"mosaicMethod",
"==",
"\"esriMosaicAttribute\"",
":",
"return",
"{",
"\"mosaicMethod\"",
":",
"\"esriMosaicAttribute\"",
",",
"\"sortField\"",
":",
"self",
".",
"_sortField",
",",
"\"sortValue\"",
":",
"self",
".",
"_sortValue",
",",
"\"ascending\"",
":",
"self",
".",
"_ascending",
",",
"\"where\"",
":",
"self",
".",
"_where",
",",
"\"fids\"",
":",
"self",
".",
"_fids",
",",
"\"mosaicOperation\"",
":",
"self",
".",
"_mosaicOperation",
"}",
"elif",
"self",
".",
"mosaicMethod",
"==",
"\"esriMosaicLockRaster\"",
":",
"return",
"{",
"\"mosaicMethod\"",
":",
"\"esriMosaicLockRaster\"",
",",
"\"lockRasterIds\"",
":",
"self",
".",
"_localRasterIds",
",",
"\"where\"",
":",
"self",
".",
"_where",
",",
"\"ascending\"",
":",
"self",
".",
"_ascending",
",",
"\"fids\"",
":",
"self",
".",
"_fids",
",",
"\"mosaicOperation\"",
":",
"self",
".",
"_mosaicOperation",
"}",
"elif",
"self",
".",
"mosaicMethod",
"==",
"\"esriMosaicSeamline\"",
":",
"return",
"{",
"\"mosaicMethod\"",
":",
"\"esriMosaicSeamline\"",
",",
"\"where\"",
":",
"self",
".",
"_where",
",",
"\"fids\"",
":",
"self",
".",
"_fids",
",",
"\"mosaicOperation\"",
":",
"self",
".",
"_mosaicOperation",
"}",
"else",
":",
"raise",
"AttributeError",
"(",
"\"Invalid Mosaic Method\"",
")"
] | gets the mosaic rule object as a dictionary | [
"gets",
"the",
"mosaic",
"rule",
"object",
"as",
"a",
"dictionary"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L478-L529 | train |
Esri/ArcREST | src/arcrest/common/general.py | FeatureSet.fromJSON | def fromJSON(jsonValue):
"""returns a featureset from a JSON string"""
jd = json.loads(jsonValue)
features = []
if 'fields' in jd:
fields = jd['fields']
else:
fields = {'fields':[]}
if 'features' in jd:
for feat in jd['features']:
wkid = None
spatialReference =None
if 'spatialReference' in jd:
spatialReference = jd['spatialReference']
if 'wkid' in jd['spatialReference']:
wkid = jd['spatialReference']['wkid']
elif 'latestWkid' in jd['spatialReference']: # kept for compatibility
wkid = jd['spatialReference']['latestWkid']
features.append(Feature(json_string=feat, wkid=wkid, spatialReference=spatialReference))
return FeatureSet(fields,
features,
hasZ=jd['hasZ'] if 'hasZ' in jd else False,
hasM=jd['hasM'] if 'hasM' in jd else False,
geometryType=jd['geometryType'] if 'geometryType' in jd else None,
objectIdFieldName=jd['objectIdFieldName'] if 'objectIdFieldName' in jd else None,
globalIdFieldName=jd['globalIdFieldName'] if 'globalIdFieldName' in jd else None,
displayFieldName=jd['displayFieldName'] if 'displayFieldName' in jd else None,
spatialReference=jd['spatialReference'] if 'spatialReference' in jd else None) | python | def fromJSON(jsonValue):
"""returns a featureset from a JSON string"""
jd = json.loads(jsonValue)
features = []
if 'fields' in jd:
fields = jd['fields']
else:
fields = {'fields':[]}
if 'features' in jd:
for feat in jd['features']:
wkid = None
spatialReference =None
if 'spatialReference' in jd:
spatialReference = jd['spatialReference']
if 'wkid' in jd['spatialReference']:
wkid = jd['spatialReference']['wkid']
elif 'latestWkid' in jd['spatialReference']: # kept for compatibility
wkid = jd['spatialReference']['latestWkid']
features.append(Feature(json_string=feat, wkid=wkid, spatialReference=spatialReference))
return FeatureSet(fields,
features,
hasZ=jd['hasZ'] if 'hasZ' in jd else False,
hasM=jd['hasM'] if 'hasM' in jd else False,
geometryType=jd['geometryType'] if 'geometryType' in jd else None,
objectIdFieldName=jd['objectIdFieldName'] if 'objectIdFieldName' in jd else None,
globalIdFieldName=jd['globalIdFieldName'] if 'globalIdFieldName' in jd else None,
displayFieldName=jd['displayFieldName'] if 'displayFieldName' in jd else None,
spatialReference=jd['spatialReference'] if 'spatialReference' in jd else None) | [
"def",
"fromJSON",
"(",
"jsonValue",
")",
":",
"jd",
"=",
"json",
".",
"loads",
"(",
"jsonValue",
")",
"features",
"=",
"[",
"]",
"if",
"'fields'",
"in",
"jd",
":",
"fields",
"=",
"jd",
"[",
"'fields'",
"]",
"else",
":",
"fields",
"=",
"{",
"'fields'",
":",
"[",
"]",
"}",
"if",
"'features'",
"in",
"jd",
":",
"for",
"feat",
"in",
"jd",
"[",
"'features'",
"]",
":",
"wkid",
"=",
"None",
"spatialReference",
"=",
"None",
"if",
"'spatialReference'",
"in",
"jd",
":",
"spatialReference",
"=",
"jd",
"[",
"'spatialReference'",
"]",
"if",
"'wkid'",
"in",
"jd",
"[",
"'spatialReference'",
"]",
":",
"wkid",
"=",
"jd",
"[",
"'spatialReference'",
"]",
"[",
"'wkid'",
"]",
"elif",
"'latestWkid'",
"in",
"jd",
"[",
"'spatialReference'",
"]",
":",
"# kept for compatibility",
"wkid",
"=",
"jd",
"[",
"'spatialReference'",
"]",
"[",
"'latestWkid'",
"]",
"features",
".",
"append",
"(",
"Feature",
"(",
"json_string",
"=",
"feat",
",",
"wkid",
"=",
"wkid",
",",
"spatialReference",
"=",
"spatialReference",
")",
")",
"return",
"FeatureSet",
"(",
"fields",
",",
"features",
",",
"hasZ",
"=",
"jd",
"[",
"'hasZ'",
"]",
"if",
"'hasZ'",
"in",
"jd",
"else",
"False",
",",
"hasM",
"=",
"jd",
"[",
"'hasM'",
"]",
"if",
"'hasM'",
"in",
"jd",
"else",
"False",
",",
"geometryType",
"=",
"jd",
"[",
"'geometryType'",
"]",
"if",
"'geometryType'",
"in",
"jd",
"else",
"None",
",",
"objectIdFieldName",
"=",
"jd",
"[",
"'objectIdFieldName'",
"]",
"if",
"'objectIdFieldName'",
"in",
"jd",
"else",
"None",
",",
"globalIdFieldName",
"=",
"jd",
"[",
"'globalIdFieldName'",
"]",
"if",
"'globalIdFieldName'",
"in",
"jd",
"else",
"None",
",",
"displayFieldName",
"=",
"jd",
"[",
"'displayFieldName'",
"]",
"if",
"'displayFieldName'",
"in",
"jd",
"else",
"None",
",",
"spatialReference",
"=",
"jd",
"[",
"'spatialReference'",
"]",
"if",
"'spatialReference'",
"in",
"jd",
"else",
"None",
")"
] | returns a featureset from a JSON string | [
"returns",
"a",
"featureset",
"from",
"a",
"JSON",
"string"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L609-L636 | train |
Esri/ArcREST | src/arcrest/common/general.py | FeatureSet.spatialReference | def spatialReference(self, value):
"""sets the featureset's spatial reference"""
if isinstance(value, SpatialReference):
self._spatialReference = value
elif isinstance(value, int):
self._spatialReference = SpatialReference(wkid=value)
elif isinstance(value, str) and \
str(value).isdigit():
self._spatialReference = SpatialReference(wkid=int(value))
elif isinstance(value, dict):
wkid = None
wkt = None
if 'wkid' in value and \
str(value['wkid']).isdigit():
wkid = int(value['wkid'])
if 'latestWkid' in value and \
str(value['latestWkid']).isdigit():
wkid = int(value['latestWkid'])
if 'wkt' in value:
wkt = value['wkt']
self._spatialReference = SpatialReference(wkid=wkid,wkt=wkt) | python | def spatialReference(self, value):
"""sets the featureset's spatial reference"""
if isinstance(value, SpatialReference):
self._spatialReference = value
elif isinstance(value, int):
self._spatialReference = SpatialReference(wkid=value)
elif isinstance(value, str) and \
str(value).isdigit():
self._spatialReference = SpatialReference(wkid=int(value))
elif isinstance(value, dict):
wkid = None
wkt = None
if 'wkid' in value and \
str(value['wkid']).isdigit():
wkid = int(value['wkid'])
if 'latestWkid' in value and \
str(value['latestWkid']).isdigit():
wkid = int(value['latestWkid'])
if 'wkt' in value:
wkt = value['wkt']
self._spatialReference = SpatialReference(wkid=wkid,wkt=wkt) | [
"def",
"spatialReference",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"SpatialReference",
")",
":",
"self",
".",
"_spatialReference",
"=",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"self",
".",
"_spatialReference",
"=",
"SpatialReference",
"(",
"wkid",
"=",
"value",
")",
"elif",
"isinstance",
"(",
"value",
",",
"str",
")",
"and",
"str",
"(",
"value",
")",
".",
"isdigit",
"(",
")",
":",
"self",
".",
"_spatialReference",
"=",
"SpatialReference",
"(",
"wkid",
"=",
"int",
"(",
"value",
")",
")",
"elif",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"wkid",
"=",
"None",
"wkt",
"=",
"None",
"if",
"'wkid'",
"in",
"value",
"and",
"str",
"(",
"value",
"[",
"'wkid'",
"]",
")",
".",
"isdigit",
"(",
")",
":",
"wkid",
"=",
"int",
"(",
"value",
"[",
"'wkid'",
"]",
")",
"if",
"'latestWkid'",
"in",
"value",
"and",
"str",
"(",
"value",
"[",
"'latestWkid'",
"]",
")",
".",
"isdigit",
"(",
")",
":",
"wkid",
"=",
"int",
"(",
"value",
"[",
"'latestWkid'",
"]",
")",
"if",
"'wkt'",
"in",
"value",
":",
"wkt",
"=",
"value",
"[",
"'wkt'",
"]",
"self",
".",
"_spatialReference",
"=",
"SpatialReference",
"(",
"wkid",
"=",
"wkid",
",",
"wkt",
"=",
"wkt",
")"
] | sets the featureset's spatial reference | [
"sets",
"the",
"featureset",
"s",
"spatial",
"reference"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L649-L669 | train |
Esri/ArcREST | src/arcrest/manageorg/_portals.py | Portals.regions | def regions(self):
"""gets the regions value"""
url = "%s/regions" % self.root
params = {"f": "json"}
return self._get(url=url,
param_dict=params,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | python | def regions(self):
"""gets the regions value"""
url = "%s/regions" % self.root
params = {"f": "json"}
return self._get(url=url,
param_dict=params,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port) | [
"def",
"regions",
"(",
"self",
")",
":",
"url",
"=",
"\"%s/regions\"",
"%",
"self",
".",
"root",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"return",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
")"
] | gets the regions value | [
"gets",
"the",
"regions",
"value"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_portals.py#L50-L57 | train |
Esri/ArcREST | src/arcrest/manageorg/_portals.py | Portals.portalSelf | def portalSelf(self):
"""The portal to which the current user belongs. This is an
organizational portal if the user belongs to an organization or the
default portal if the user does not belong to one"""
url = "%s/self" % self.root
return Portal(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
) | python | def portalSelf(self):
"""The portal to which the current user belongs. This is an
organizational portal if the user belongs to an organization or the
default portal if the user does not belong to one"""
url = "%s/self" % self.root
return Portal(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
) | [
"def",
"portalSelf",
"(",
"self",
")",
":",
"url",
"=",
"\"%s/self\"",
"%",
"self",
".",
"root",
"return",
"Portal",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
")"
] | The portal to which the current user belongs. This is an
organizational portal if the user belongs to an organization or the
default portal if the user does not belong to one | [
"The",
"portal",
"to",
"which",
"the",
"current",
"user",
"belongs",
".",
"This",
"is",
"an",
"organizational",
"portal",
"if",
"the",
"user",
"belongs",
"to",
"an",
"organization",
"or",
"the",
"default",
"portal",
"if",
"the",
"user",
"does",
"not",
"belong",
"to",
"one"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_portals.py#L80-L89 | train |
Esri/ArcREST | src/arcrest/manageorg/_portals.py | Portals.portal | def portal(self, portalID=None):
"""returns a specific reference to a portal"""
if portalID is None:
portalID = self.portalSelf.id
url = "%s/%s" % (self.root, portalID)
return Portal(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initalize=True) | python | def portal(self, portalID=None):
"""returns a specific reference to a portal"""
if portalID is None:
portalID = self.portalSelf.id
url = "%s/%s" % (self.root, portalID)
return Portal(url=url,
securityHandler=self._securityHandler,
proxy_url=self._proxy_url,
proxy_port=self._proxy_port,
initalize=True) | [
"def",
"portal",
"(",
"self",
",",
"portalID",
"=",
"None",
")",
":",
"if",
"portalID",
"is",
"None",
":",
"portalID",
"=",
"self",
".",
"portalSelf",
".",
"id",
"url",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"root",
",",
"portalID",
")",
"return",
"Portal",
"(",
"url",
"=",
"url",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"initalize",
"=",
"True",
")"
] | returns a specific reference to a portal | [
"returns",
"a",
"specific",
"reference",
"to",
"a",
"portal"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_portals.py#L91-L100 | train |
Esri/ArcREST | src/arcrest/manageorg/_portals.py | Portal._findPortalId | def _findPortalId(self):
"""gets the portal id for a site if not known."""
if not self.root.lower().endswith("/self"):
url = self.root + "/self"
else:
url = self.root
params = {
"f" : "json"
}
res = self._get(url=url, param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
if 'id' in res:
return res['id']
return None | python | def _findPortalId(self):
"""gets the portal id for a site if not known."""
if not self.root.lower().endswith("/self"):
url = self.root + "/self"
else:
url = self.root
params = {
"f" : "json"
}
res = self._get(url=url, param_dict=params,
securityHandler=self._securityHandler,
proxy_port=self._proxy_port,
proxy_url=self._proxy_url)
if 'id' in res:
return res['id']
return None | [
"def",
"_findPortalId",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"root",
".",
"lower",
"(",
")",
".",
"endswith",
"(",
"\"/self\"",
")",
":",
"url",
"=",
"self",
".",
"root",
"+",
"\"/self\"",
"else",
":",
"url",
"=",
"self",
".",
"root",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"res",
"=",
"self",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
",",
"securityHandler",
"=",
"self",
".",
"_securityHandler",
",",
"proxy_port",
"=",
"self",
".",
"_proxy_port",
",",
"proxy_url",
"=",
"self",
".",
"_proxy_url",
")",
"if",
"'id'",
"in",
"res",
":",
"return",
"res",
"[",
"'id'",
"]",
"return",
"None"
] | gets the portal id for a site if not known. | [
"gets",
"the",
"portal",
"id",
"for",
"a",
"site",
"if",
"not",
"known",
"."
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_portals.py#L248-L263 | train |
Esri/ArcREST | src/arcrest/manageorg/_portals.py | Portal.portalId | def portalId(self):
"""gets the portal Id"""
if self._portalId is None:
self._portalId = self._findPortalId()
return self._portalId | python | def portalId(self):
"""gets the portal Id"""
if self._portalId is None:
self._portalId = self._findPortalId()
return self._portalId | [
"def",
"portalId",
"(",
"self",
")",
":",
"if",
"self",
".",
"_portalId",
"is",
"None",
":",
"self",
".",
"_portalId",
"=",
"self",
".",
"_findPortalId",
"(",
")",
"return",
"self",
".",
"_portalId"
] | gets the portal Id | [
"gets",
"the",
"portal",
"Id"
] | ab240fde2b0200f61d4a5f6df033516e53f2f416 | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_portals.py#L384-L388 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.