idx int64 0 251k | question stringlengths 53 3.53k | target stringlengths 5 1.23k | len_question int64 20 893 | len_target int64 3 238 |
|---|---|---|---|---|
244,900 | 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 | 381 | 9 |
244,901 | 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 | 229 | 7 |
244,902 | 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 | 67 | 4 |
244,903 | 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 | 57 | 33 |
244,904 | 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 | 87 | 8 |
244,905 | 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 . | 120 | 11 |
244,906 | def portalId ( self ) : if self . _portalId is None : self . _portalId = self . _findPortalId ( ) return self . _portalId | gets the portal Id | 40 | 4 |
244,907 | def featureServers ( self ) : if self . urls == { } : return { } featuresUrls = self . urls [ 'urls' ] [ 'features' ] if 'https' in featuresUrls : res = featuresUrls [ 'https' ] elif 'http' in featuresUrls : res = featuresUrls [ 'http' ] else : return None services = [ ] for urlHost in res : if self . isPortal : services . append ( AGSAdministration ( url = '%s/admin' % urlHost , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) else : services . append ( Services ( url = 'https://%s/%s/ArcGIS/admin' % ( urlHost , self . portalId ) , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return services | gets the hosting feature AGS Server | 222 | 7 |
244,908 | def update ( self , updatePortalParameters , clearEmptyFields = False ) : url = self . root + "/update" params = { "f" : "json" , "clearEmptyFields" : clearEmptyFields } if isinstance ( updatePortalParameters , parameters . PortalParameters ) : params . update ( updatePortalParameters . value ) elif isinstance ( updatePortalParameters , dict ) : for k , v in updatePortalParameters . items ( ) : params [ k ] = v else : raise AttributeError ( "updatePortalParameters must be of type parameter.PortalParameters" ) return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The Update operation allows administrators only to update the organization information such as name description thumbnail and featured groups . | 179 | 20 |
244,909 | def updateUserRole ( self , user , role ) : url = self . _url + "/updateuserrole" params = { "f" : "json" , "user" : user , "role" : role } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The Update User Role operation allows the administrator of an org anization to update the role of a user within a portal . | 94 | 24 |
244,910 | def isServiceNameAvailable ( self , name , serviceType ) : _allowedTypes = [ 'Feature Service' , "Map Service" ] url = self . _url + "/isServiceNameAvailable" params = { "f" : "json" , "name" : name , "type" : serviceType } return self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Checks to see if a given service name and type are available for publishing a new service . true indicates that the name and type is not found in the organization s services and is available for publishing . false means the requested name and type are not available . | 113 | 51 |
244,911 | def servers ( self ) : url = "%s/servers" % self . root return Servers ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | gets the federated or registered servers for Portal | 57 | 9 |
244,912 | def users ( self , start = 1 , num = 10 , sortField = "fullName" , sortOrder = "asc" , role = None ) : users = [ ] url = self . _url + "/users" params = { "f" : "json" , "start" : start , "num" : num } if not role is None : params [ 'role' ] = role if not sortField is None : params [ 'sortField' ] = sortField if not sortOrder is None : params [ 'sortOrder' ] = sortOrder from . _community import Community res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) if "users" in res : if len ( res [ 'users' ] ) > 0 : parsed = urlparse . urlparse ( self . _url ) if parsed . netloc . lower ( ) . find ( 'arcgis.com' ) == - 1 : cURL = "%s://%s/%s/sharing/rest/community" % ( parsed . scheme , parsed . netloc , parsed . path [ 1 : ] . split ( '/' ) [ 0 ] ) else : cURL = "%s://%s/sharing/rest/community" % ( parsed . scheme , parsed . netloc ) com = Community ( url = cURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) for r in res [ 'users' ] : users . append ( com . users . user ( r [ "username" ] ) ) res [ 'users' ] = users return res | Lists all the members of the organization . The start and num paging parameters are supported . | 381 | 19 |
244,913 | def roles ( self ) : return Roles ( url = "%s/roles" % self . root , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | gets the roles class that allows admins to manage custom roles on portal | 54 | 13 |
244,914 | def resources ( self , start = 1 , num = 10 ) : url = self . _url + "/resources" params = { "f" : "json" , "start" : start , "num" : num } return self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Resources lists all file resources for the organization . The start and num paging parameters are supported . | 94 | 19 |
244,915 | def addResource ( self , key , filePath , text ) : url = self . root + "/addresource" params = { "f" : "json" , "token" : self . _securityHandler . token , "key" : key , "text" : text } files = { } files [ 'file' ] = filePath res = self . _post ( url = url , param_dict = params , files = files , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) return res | The add resource operation allows the administrator to add a file resource for example the organization s logo or custom banner . The resource can be used by any member of the organization . File resources use storage space from your quota and are scanned for viruses . | 126 | 48 |
244,916 | def updateSecurityPolicy ( self , minLength = 8 , minUpper = None , minLower = None , minLetter = None , minDigit = None , minOther = None , expirationInDays = None , historySize = None ) : params = { "f" : "json" , "minLength" : minLength , "minUpper" : minUpper , "minLower" : minLower , "minLetter" : minLetter , "minDigit" : minDigit , "minOther" : minOther , "expirationInDays" : expirationInDays , "historySize" : historySize } url = "%s/securityPolicy/update" % self . root return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | updates the Portals security policy | 194 | 7 |
244,917 | def portalAdmin ( self ) : from . . manageportal import PortalAdministration return PortalAdministration ( admin_url = "https://%s/portaladmin" % self . portalHostname , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = False ) | gets a reference to a portal administration class | 80 | 8 |
244,918 | def addUser ( self , invitationList , subject , html ) : url = self . _url + "/invite" params = { "f" : "json" } if isinstance ( invitationList , parameters . InvitationList ) : params [ 'invitationList' ] = invitationList . value ( ) params [ 'html' ] = html params [ 'subject' ] = subject return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | adds a user without sending an invitation email | 128 | 9 |
244,919 | def inviteByEmail ( self , emails , subject , text , html , role = "org_user" , mustApprove = True , expiration = 1440 ) : url = self . root + "/inviteByEmail" params = { "f" : "json" , "emails" : emails , "subject" : subject , "text" : text , "html" : html , "role" : role , "mustApprove" : mustApprove , "expiration" : expiration } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Invites a user or users to a site . | 155 | 10 |
244,920 | def usage ( self , startTime , endTime , vars = None , period = None , groupby = None , name = None , stype = None , etype = None , appId = None , deviceId = None , username = None , appOrgId = None , userOrgId = None , hostOrgId = None ) : url = self . root + "/usage" startTime = str ( int ( local_time_to_online ( dt = startTime ) ) ) endTime = str ( int ( local_time_to_online ( dt = endTime ) ) ) params = { 'f' : 'json' , 'startTime' : startTime , 'endTime' : endTime , 'vars' : vars , 'period' : period , 'groupby' : groupby , 'name' : name , 'stype' : stype , 'etype' : etype , 'appId' : appId , 'deviceId' : deviceId , 'username' : username , 'appOrgId' : appOrgId , 'userOrgId' : userOrgId , 'hostOrgId' : hostOrgId , } params = { key : item for key , item in params . items ( ) if item is not None } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | returns the usage statistics value | 320 | 6 |
244,921 | def servers ( self ) : self . __init ( ) items = [ ] for k , v in self . _json_dict . items ( ) : if k == "servers" : for s in v : if 'id' in s : url = "%s/%s" % ( self . root , s [ 'id' ] ) items . append ( self . Server ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) del k , v return items | gets all the server resources | 123 | 5 |
244,922 | def deleteRole ( self , roleID ) : url = self . _url + "/%s/delete" % roleID params = { "f" : "json" } return self . _post ( url = url , param_dict = params , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | deletes a role by ID | 75 | 6 |
244,923 | def updateRole ( self , roleID , name , description ) : params = { "name" : name , "description" : description , "f" : "json" } url = self . _url + "/%s/update" return self . _post ( url = url , param_dict = params , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | allows for the role name or description to be modified | 88 | 10 |
244,924 | def findRoleID ( self , name ) : for r in self : if r [ 'name' ] . lower ( ) == name . lower ( ) : return r [ 'id' ] del r return None | searches the roles by name and returns the role s ID | 44 | 13 |
244,925 | def get_config_value ( config_file , section , variable ) : try : parser = ConfigParser . SafeConfigParser ( ) parser . read ( config_file ) return parser . get ( section , variable ) except : return None | extracts a config file value | 49 | 7 |
244,926 | def users ( self ) : return Users ( url = "%s/users" % self . root , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Provides access to all user resources | 52 | 7 |
244,927 | def getItem ( self , itemId ) : url = "%s/items/%s" % ( self . root , itemId ) return Item ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | gets the refernce to the Items class which manages content on a given AGOL or Portal site . | 67 | 21 |
244,928 | def FeatureContent ( self ) : return FeatureContent ( url = "%s/%s" % ( self . root , "features" ) , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Feature Content class id the parent resource for feature operations such as Analyze and Generate . | 61 | 18 |
244,929 | def user ( self , username = None ) : if username is None : username = self . __getUsername ( ) url = "%s/%s" % ( self . root , username ) return User ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = True ) | gets the user s content . If None is passed the current user is used . | 85 | 16 |
244,930 | def saveThumbnail ( self , fileName , filePath ) : if self . _thumbnail is None : self . __init ( ) param_dict = { } if self . _thumbnail is not None : imgUrl = self . root + "/info/" + self . _thumbnail onlineFileName , file_ext = splitext ( self . _thumbnail ) fileNameSafe = "" . join ( x for x in fileName if x . isalnum ( ) ) + file_ext result = self . _get ( url = imgUrl , param_dict = param_dict , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = filePath , file_name = fileNameSafe ) return result else : return None | URL to the thumbnail used for the item | 177 | 8 |
244,931 | def userItem ( self ) : if self . ownerFolder is not None : url = "%s/users/%s/%s/items/%s" % ( self . root . split ( '/items/' ) [ 0 ] , self . owner , self . ownerFolder , self . id ) else : url = "%s/users/%s/items/%s" % ( self . root . split ( '/items/' ) [ 0 ] , self . owner , self . id ) return UserItem ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | returns a reference to the UserItem class | 145 | 9 |
244,932 | def addRating ( self , rating = 5.0 ) : if rating > 5.0 : rating = 5.0 elif rating < 1.0 : rating = 1.0 url = "%s/addRating" % self . root params = { "f" : "json" , "rating" : "%s" % rating } return self . _post ( url , params , proxy_port = self . _proxy_port , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url ) | Adds a rating to an item between 1 . 0 and 5 . 0 | 112 | 14 |
244,933 | def addComment ( self , comment ) : url = "%s/addComment" % self . root params = { "f" : "json" , "comment" : comment } return self . _post ( url , params , proxy_port = self . _proxy_port , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url ) | adds a comment to a given item . Must be authenticated | 79 | 12 |
244,934 | def itemComment ( self , commentId ) : url = "%s/comments/%s" % ( self . root , commentId ) params = { "f" : "json" } return self . _get ( url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | returns details of a single comment | 81 | 7 |
244,935 | def itemComments ( self ) : url = "%s/comments/" % self . root params = { "f" : "json" } return self . _get ( url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | returns all comments for a given item | 70 | 8 |
244,936 | def deleteComment ( self , commentId ) : url = "%s/comments/%s/delete" % ( self . root , commentId ) params = { "f" : "json" , } return self . _post ( url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | removes a comment from an Item | 84 | 7 |
244,937 | def packageInfo ( self ) : url = "%s/item.pkinfo" % self . root params = { 'f' : 'json' } result = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = tempfile . gettempdir ( ) ) return result | gets the item s package information file | 96 | 7 |
244,938 | def item ( self ) : url = self . _contentURL return Item ( url = self . _contentURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = True ) | returns the Item class of an Item | 61 | 8 |
244,939 | def reassignItem ( self , targetUsername , targetFoldername ) : params = { "f" : "json" , "targetUsername" : targetUsername , "targetFoldername" : targetFoldername } url = "%s/reassign" % self . root return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The Reassign Item operation allows the administrator of an organization to reassign a member s item to another member of the organization . | 110 | 26 |
244,940 | def updateItem ( self , itemParameters , clearEmptyFields = False , data = None , metadata = None , text = None , serviceUrl = None , multipart = False ) : thumbnail = None largeThumbnail = None files = { } params = { "f" : "json" , } if clearEmptyFields : params [ "clearEmptyFields" ] = clearEmptyFields if serviceUrl is not None : params [ 'url' ] = serviceUrl if text is not None : params [ 'text' ] = text if isinstance ( itemParameters , ItemParameter ) == False : raise AttributeError ( "itemParameters must be of type parameter.ItemParameter" ) keys_to_delete = [ 'id' , 'owner' , 'size' , 'numComments' , 'numRatings' , 'avgRating' , 'numViews' , 'overwrite' ] dictItem = itemParameters . value for key in keys_to_delete : if key in dictItem : del dictItem [ key ] for key in dictItem : if key == "thumbnail" : files [ 'thumbnail' ] = dictItem [ 'thumbnail' ] elif key == "largeThumbnail" : files [ 'largeThumbnail' ] = dictItem [ 'largeThumbnail' ] elif key == "metadata" : metadata = dictItem [ 'metadata' ] if os . path . basename ( metadata ) != 'metadata.xml' : tempxmlfile = os . path . join ( tempfile . gettempdir ( ) , "metadata.xml" ) if os . path . isfile ( tempxmlfile ) == True : os . remove ( tempxmlfile ) import shutil shutil . copy ( metadata , tempxmlfile ) metadata = tempxmlfile files [ 'metadata' ] = dictItem [ 'metadata' ] else : params [ key ] = dictItem [ key ] if data is not None : files [ 'file' ] = data if metadata and os . path . isfile ( metadata ) : files [ 'metadata' ] = metadata url = "%s/update" % self . root if multipart : itemID = self . id params [ 'multipart' ] = True params [ 'fileName' ] = os . path . basename ( data ) res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) itemPartJSON = self . addByPart ( filePath = data ) res = self . commit ( wait = True , additionalParams = { 'type' : self . type } ) else : res = self . _post ( url = url , param_dict = params , files = files , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , force_form_post = True ) self . __init ( ) return self | updates an item s properties using the ItemParameter class . | 650 | 12 |
244,941 | def status ( self , jobId = None , jobType = None ) : params = { "f" : "json" } if jobType is not None : params [ 'jobType' ] = jobType if jobId is not None : params [ "jobId" ] = jobId url = "%s/status" % self . root return self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | Inquire about status when publishing an item adding an item in async mode or adding with a multipart upload . Partial is available for Add Item Multipart when only a part is uploaded and the item is not committed . | 119 | 44 |
244,942 | def commit ( self , wait = False , additionalParams = { } ) : url = "%s/commit" % self . root params = { "f" : "json" , } for key , value in additionalParams . items ( ) : params [ key ] = value if wait == True : res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) res = self . status ( ) import time while res [ 'status' ] . lower ( ) in [ "partial" , "processing" ] : time . sleep ( 2 ) res = self . status ( ) return res else : return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | Commit is called once all parts are uploaded during a multipart Add Item or Update Item operation . The parts are combined into a file and the original file is overwritten during an Update Item operation . This is an asynchronous call and returns immediately . Status can be used to check the status of the operation until it is completed . | 207 | 65 |
244,943 | def folders ( self ) : if self . _folders is None : self . __init ( ) if self . _folders is not None and isinstance ( self . _folders , list ) : if len ( self . _folders ) == 0 : self . _loadFolders ( ) return self . _folders | gets the property value for folders | 70 | 6 |
244,944 | def items ( self ) : self . __init ( ) items = [ ] for item in self . _items : items . append ( UserItem ( url = "%s/items/%s" % ( self . location , item [ 'id' ] ) , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = True ) ) return items | gets the property value for items | 95 | 6 |
244,945 | def addRelationship ( self , originItemId , destinationItemId , relationshipType ) : url = "%s/addRelationship" % self . root params = { "originItemId" : originItemId , "destinationItemId" : destinationItemId , "relationshipType" : relationshipType , "f" : "json" } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | Adds a relationship of a certain type between two items . | 120 | 11 |
244,946 | def createService ( self , createServiceParameter , description = None , tags = "Feature Service" , snippet = None ) : url = "%s/createService" % self . location val = createServiceParameter . value params = { "f" : "json" , "outputType" : "featureService" , "createParameters" : json . dumps ( val ) , "tags" : tags } if snippet is not None : params [ 'snippet' ] = snippet if description is not None : params [ 'description' ] = description res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) if 'id' in res or 'serviceItemId' in res : if 'id' in res : url = "%s/items/%s" % ( self . location , res [ 'id' ] ) else : url = "%s/items/%s" % ( self . location , res [ 'serviceItemId' ] ) return UserItem ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) return res | The Create Service operation allows users to create a hosted feature service . You can use the API to create an empty hosted feaure service from feature service metadata JSON . | 275 | 33 |
244,947 | def shareItems ( self , items , groups = "" , everyone = False , org = False ) : url = "%s/shareItems" % self . root params = { "f" : "json" , "items" : items , "everyone" : everyone , "org" : org , "groups" : groups } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | Shares a batch of items with the specified list of groups . Users can only share items with groups to which they belong . This operation also allows a user to share items with everyone in which case the items are publicly accessible or with everyone in their organization . | 115 | 50 |
244,948 | def createFolder ( self , name ) : url = "%s/createFolder" % self . root params = { "f" : "json" , "title" : name } self . _folders = None return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | Creates a folder in which items can be placed . Folders are only visible to a user and solely used for organizing content within that user s content space . | 92 | 32 |
244,949 | def analyze ( self , itemId = None , filePath = None , text = None , fileType = "csv" , analyzeParameters = None ) : files = [ ] url = self . _url + "/analyze" params = { "f" : "json" } fileType = "csv" params [ "fileType" ] = fileType if analyzeParameters is not None and isinstance ( analyzeParameters , AnalyzeParameters ) : params [ 'analyzeParameters' ] = analyzeParameters . value if not ( filePath is None ) and os . path . isfile ( filePath ) : params [ 'text' ] = open ( filePath , 'rb' ) . read ( ) return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) elif itemId is not None : params [ "fileType" ] = fileType params [ 'itemId' ] = itemId return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) else : raise AttributeError ( "either an Item ID or a file path must be given." ) | The Analyze call helps a client analyze a CSV file prior to publishing or generating features using the Publish or Generate operation respectively . Analyze returns information about the file including the fields present as well as sample records . Analyze attempts to detect the presence of location fields that may be present as either X Y fields or address fields . Analyze packages its result so that publishParameters within the JSON response contains information that can be passed back to the server in a subsequent call to Publish or Generate . The publishParameters subobject contains properties that describe the resulting layer after publishing including its fields the desired renderer and so on . Analyze will suggest defaults for the renderer . In a typical workflow the client will present portions of the Analyze results to the user for editing before making the call to Publish or Generate . If the file to be analyzed currently exists in the portal as an item callers can pass in its itemId . Callers can also directly post the file . In this case the request must be a multipart post request pursuant to IETF RFC1867 . The third option for text files is to pass the text in as the value of the text parameter . | 288 | 238 |
244,950 | def __assembleURL ( self , url , groupId ) : from . . packages . six . moves . urllib_parse import urlparse parsed = urlparse ( url ) communityURL = "%s://%s%s/sharing/rest/community/groups/%s" % ( parsed . scheme , parsed . netloc , parsed . path . lower ( ) . split ( '/sharing/rest/' ) [ 0 ] , groupId ) return communityURL | private function that assembles the URL for the community . Group class | 98 | 13 |
244,951 | def group ( self ) : split_count = self . _url . lower ( ) . find ( "/content/" ) len_count = len ( '/content/' ) gURL = self . _url [ : self . _url . lower ( ) . find ( "/content/" ) ] + "/community/" + self . _url [ split_count + len_count : ] #self.__assembleURL(self._contentURL, self._groupId) return CommunityGroup ( url = gURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | returns the community . Group class for the current group | 138 | 11 |
244,952 | def addUniqueValue ( self , value , label , description , symbol ) : if self . _uniqueValueInfos is None : self . _uniqueValueInfos = [ ] self . _uniqueValueInfos . append ( { "value" : value , "label" : label , "description" : description , "symbol" : symbol } ) | adds a unique value to the renderer | 74 | 9 |
244,953 | def removeUniqueValue ( self , value ) : for v in self . _uniqueValueInfos : if v [ 'value' ] == value : self . _uniqueValueInfos . remove ( v ) return True del v return False | removes a unique value in unique Value Info | 49 | 9 |
244,954 | def addClassBreak ( self , classMinValue , classMaxValue , label , description , symbol ) : if self . _classBreakInfos is None : self . _classBreakInfos = [ ] self . _classBreakInfos . append ( { "classMinValue" : classMinValue , "classMaxValue" : classMaxValue , "label" : label , "description" : description , "symbol" : symbol } ) | adds a classification break value to the renderer | 94 | 10 |
244,955 | def removeClassBreak ( self , label ) : for v in self . _classBreakInfos : if v [ 'label' ] == label : self . _classBreakInfos . remove ( v ) return True del v return False | removes a classification break value to the renderer | 49 | 10 |
244,956 | def downloadThumbnail ( self , outPath ) : url = self . _url + "/info/thumbnail" params = { } return self . _get ( url = url , out_folder = outPath , file_name = None , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | downloads the items s thumbnail | 87 | 6 |
244,957 | def __init ( self ) : params = { "f" : "json" } json_dict = self . _get ( self . _url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . _json = json . dumps ( json_dict ) self . _json_dict = json_dict attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k == "tables" : self . _tables = [ ] for tbl in v : url = self . _url + "/%s" % tbl [ 'id' ] self . _tables . append ( TableLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif k == "layers" : self . _layers = [ ] for lyr in v : url = self . _url + "/%s" % lyr [ 'id' ] layer_type = self . _getLayerType ( url ) if layer_type == "Feature Layer" : self . _layers . append ( FeatureLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif layer_type == "Raster Layer" : self . _layers . append ( RasterLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif layer_type == "Group Layer" : self . _layers . append ( GroupLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif layer_type == "Schematics Layer" : self . _layers . append ( SchematicsLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) else : print ( 'Type %s is not implemented' % layer_type ) elif k in attributes : setattr ( self , "_" + k , json_dict [ k ] ) else : print ( k , " is not implemented for mapservice." ) | populates all the properties for the map service | 565 | 9 |
244,958 | def getExtensions ( self ) : extensions = [ ] if isinstance ( self . supportedExtensions , list ) : for ext in self . supportedExtensions : extensionURL = self . _url + "/exts/%s" % ext if ext == "SchematicsServer" : extensions . append ( SchematicsService ( url = extensionURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return extensions else : extensionURL = self . _url + "/exts/%s" % self . supportedExtensions if self . supportedExtensions == "SchematicsServer" : extensions . append ( SchematicsService ( url = extensionURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return extensions | returns objects for all map service extensions | 194 | 8 |
244,959 | def allLayers ( self ) : url = self . _url + "/layers" params = { "f" : "json" } res = self . _get ( url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) return_dict = { "layers" : [ ] , "tables" : [ ] } for k , v in res . items ( ) : if k == "layers" : for val in v : return_dict [ 'layers' ] . append ( FeatureLayer ( url = self . _url + "/%s" % val [ 'id' ] , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) elif k == "tables" : for val in v : return_dict [ 'tables' ] . append ( TableLayer ( url = self . _url + "/%s" % val [ 'id' ] , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) del k , v return return_dict | returns all layers for the service | 275 | 7 |
244,960 | def find ( self , searchText , layers , contains = True , searchFields = "" , sr = "" , layerDefs = "" , returnGeometry = True , maxAllowableOffset = "" , geometryPrecision = "" , dynamicLayers = "" , returnZ = False , returnM = False , gdbVersion = "" ) : url = self . _url + "/find" #print url params = { "f" : "json" , "searchText" : searchText , "contains" : self . _convert_boolean ( contains ) , "searchFields" : searchFields , "sr" : sr , "layerDefs" : layerDefs , "returnGeometry" : self . _convert_boolean ( returnGeometry ) , "maxAllowableOffset" : maxAllowableOffset , "geometryPrecision" : geometryPrecision , "dynamicLayers" : dynamicLayers , "returnZ" : self . _convert_boolean ( returnZ ) , "returnM" : self . _convert_boolean ( returnM ) , "gdbVersion" : gdbVersion , "layers" : layers } res = self . _get ( url , params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) qResults = [ ] for r in res [ 'results' ] : qResults . append ( Feature ( r ) ) return qResults | performs the map service find operation | 324 | 7 |
244,961 | def getFeatureDynamicLayer ( self , oid , dynamicLayer , returnZ = False , returnM = False ) : url = self . _url + "/dynamicLayer/%s" % oid params = { "f" : "json" , "returnZ" : returnZ , "returnM" : returnM , "layer" : { "id" : 101 , "source" : dynamicLayer . asDictionary } } return Feature ( json_string = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) | The feature resource represents a single feature in a dynamic layer in a map service | 147 | 15 |
244,962 | def identify ( self , geometry , mapExtent , imageDisplay , tolerance , geometryType = "esriGeometryPoint" , sr = None , layerDefs = None , time = None , layerTimeOptions = None , layers = "top" , returnGeometry = True , maxAllowableOffset = None , geometryPrecision = None , dynamicLayers = None , returnZ = False , returnM = False , gdbVersion = None ) : params = { 'f' : 'json' , 'geometry' : geometry , 'geometryType' : geometryType , 'tolerance' : tolerance , 'mapExtent' : mapExtent , 'imageDisplay' : imageDisplay } if layerDefs is not None : params [ 'layerDefs' ] = layerDefs if layers is not None : params [ 'layers' ] = layers if sr is not None : params [ 'sr' ] = sr if time is not None : params [ 'time' ] = time if layerTimeOptions is not None : params [ 'layerTimeOptions' ] = layerTimeOptions if maxAllowableOffset is not None : params [ 'maxAllowableOffset' ] = maxAllowableOffset if geometryPrecision is not None : params [ 'geometryPrecision' ] = geometryPrecision if dynamicLayers is not None : params [ 'dynamicLayers' ] = dynamicLayers if gdbVersion is not None : params [ 'gdbVersion' ] = gdbVersion identifyURL = self . _url + "/identify" return self . _get ( url = identifyURL , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The identify operation is performed on a map service resource to discover features at a geographic location . The result of this operation is an identify results resource . Each identified result includes its name layer ID layer name geometry and geometry type and other attributes of that result as name - value pairs . | 375 | 55 |
244,963 | def fromJSON ( value ) : if isinstance ( value , str ) : value = json . loads ( value ) elif isinstance ( value , dict ) : pass else : raise AttributeError ( "Invalid input" ) return Extension ( typeName = value [ 'typeName' ] , capabilities = value [ 'capabilities' ] , enabled = value [ 'enabled' ] == "true" , maxUploadFileSize = value [ 'maxUploadFileSize' ] , allowedUploadFileType = value [ 'allowedUploadFileTypes' ] , properties = value [ 'properties' ] ) | returns the object from json string or dictionary | 123 | 9 |
244,964 | def asList ( self ) : return [ self . _red , self . _green , self . _blue , self . _alpha ] | returns the value as the list object | 29 | 8 |
244,965 | def color ( self , value ) : if isinstance ( value , ( list , Color ) ) : if value is list : self . _color = value else : self . _color = value . asList | sets the color | 43 | 3 |
244,966 | def outlineColor ( self , value ) : if isinstance ( value , ( list , Color ) ) : if value is list : self . _outlineColor = value else : self . _outlineColor = value . asList | sets the outline color | 48 | 4 |
244,967 | def outline ( self , value ) : if isinstance ( value , SimpleLineSymbol ) : self . _outline = value . asDictionary | sets the outline | 31 | 3 |
244,968 | def base64ToImage ( imgData , out_path , out_file ) : fh = open ( os . path . join ( out_path , out_file ) , "wb" ) fh . write ( imgData . decode ( 'base64' ) ) fh . close ( ) del fh return os . path . join ( out_path , out_file ) | converts a base64 string to a file | 82 | 9 |
244,969 | def find ( self , text , magicKey = None , sourceCountry = None , bbox = None , location = None , distance = 3218.69 , outSR = 102100 , category = None , outFields = "*" , maxLocations = 20 , forStorage = False ) : if isinstance ( self . _securityHandler , ( AGOLTokenSecurityHandler , OAuthSecurityHandler ) ) : url = self . _url + "/find" params = { "f" : "json" , "text" : text , #"token" : self._securityHandler.token } if not magicKey is None : params [ 'magicKey' ] = magicKey if not sourceCountry is None : params [ 'sourceCountry' ] = sourceCountry if not bbox is None : params [ 'bbox' ] = bbox if not location is None : if isinstance ( location , Point ) : params [ 'location' ] = location . asDictionary if isinstance ( location , list ) : params [ 'location' ] = "%s,%s" % ( location [ 0 ] , location [ 1 ] ) if not distance is None : params [ 'distance' ] = distance if not outSR is None : params [ 'outSR' ] = outSR if not category is None : params [ 'category' ] = category if outFields is None : params [ 'outFields' ] = "*" else : params [ 'outFields' ] = outFields if not maxLocations is None : params [ 'maxLocations' ] = maxLocations if not forStorage is None : params [ 'forStorage' ] = forStorage return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) else : raise Exception ( "This function works on the ArcGIS Online World Geocoder" ) | The find operation geocodes one location per request ; the input address is specified in a single parameter . | 422 | 21 |
244,970 | def geocodeAddresses ( self , addresses , outSR = 4326 , sourceCountry = None , category = None ) : params = { "f" : "json" } url = self . _url + "/geocodeAddresses" params [ 'outSR' ] = outSR params [ 'sourceCountry' ] = sourceCountry params [ 'category' ] = category params [ 'addresses' ] = addresses return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The geocodeAddresses operation is performed on a Geocode Service resource . The result of this operation is a resource representing the list of geocoded addresses . This resource provides information about the addresses including the address location score and other geocode service - specific attributes . You can provide arguments to the geocodeAddresses operation as query parameters defined in the following parameters table . | 136 | 78 |
244,971 | def __init ( self ) : params = { "f" : "json" , } json_dict = self . _get ( self . _url , params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _json_dict = json_dict self . _json = json . dumps ( self . _json_dict ) attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k in attributes : if k == "routeLayers" and json_dict [ k ] : self . _routeLayers = [ ] for rl in v : self . _routeLayers . append ( RouteNetworkLayer ( url = self . _url + "/%s" % rl , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) elif k == "serviceAreaLayers" and json_dict [ k ] : self . _serviceAreaLayers = [ ] for sal in v : self . _serviceAreaLayers . append ( ServiceAreaNetworkLayer ( url = self . _url + "/%s" % sal , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) elif k == "closestFacilityLayers" and json_dict [ k ] : self . _closestFacilityLayers = [ ] for cf in v : self . _closestFacilityLayers . append ( ClosestFacilityNetworkLayer ( url = self . _url + "/%s" % cf , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) else : setattr ( self , "_" + k , v ) else : print ( "attribute %s is not implemented." % k ) | initializes the properties | 482 | 4 |
244,972 | def __init ( self ) : params = { "f" : "json" } json_dict = self . _get ( url = self . _url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k in attributes : setattr ( self , "_" + k , json_dict [ k ] ) else : print ( k , " - attribute not implemented in RouteNetworkLayer." ) del k , v | initializes all the properties | 167 | 5 |
244,973 | def download ( self , itemID , savePath ) : if os . path . isdir ( savePath ) == False : os . makedirs ( savePath ) url = self . _url + "/%s/download" % itemID params = { } if len ( params . keys ( ) ) : url = url + "?%s" % urlencode ( params ) return self . _get ( url = url , param_dict = params , out_folder = savePath , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | downloads an item to local disk | 135 | 7 |
244,974 | def reports ( self ) : if self . _metrics is None : self . __init ( ) self . _reports = [ ] for r in self . _metrics : url = self . _url + "/%s" % six . moves . urllib . parse . quote_plus ( r [ 'reportname' ] ) self . _reports . append ( UsageReport ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = True ) ) del url return self . _reports | returns a list of reports on the server | 128 | 9 |
244,975 | def editUsageReportSettings ( self , samplingInterval , enabled = True , maxHistory = 0 ) : params = { "f" : "json" , "maxHistory" : maxHistory , "enabled" : enabled , "samplingInterval" : samplingInterval } url = self . _url + "/settings/edit" return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The usage reports settings are applied to the entire site . A POST request updates the usage reports settings . | 117 | 20 |
244,976 | def createUsageReport ( self , reportname , queries , metadata , since = "LAST_DAY" , fromValue = None , toValue = None , aggregationInterval = None ) : url = self . _url + "/add" params = { "f" : "json" , "usagereport" : { "reportname" : reportname , "since" : since , "metadata" : metadata } } if isinstance ( queries , dict ) : params [ "usagereport" ] [ "queries" ] = [ queries ] elif isinstance ( queries , list ) : params [ "usagereport" ] [ "queries" ] = queries if aggregationInterval is not None : params [ "usagereport" ] [ 'aggregationInterval' ] = aggregationInterval if since . lower ( ) == "custom" : params [ "usagereport" ] [ 'to' ] = toValue params [ "usagereport" ] [ 'from' ] = fromValue res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) # Refresh the metrics object self . __init ( ) return res | Creates a new usage report . A usage report is created by submitting a JSON representation of the usage report to this operation . | 268 | 25 |
244,977 | def edit ( self ) : usagereport_dict = { "reportname" : self . reportname , "queries" : self . _queries , "since" : self . since , "metadata" : self . _metadata , "to" : self . _to , "from" : self . _from , "aggregationInterval" : self . _aggregationInterval } params = { "f" : "json" , "usagereport" : json . dumps ( usagereport_dict ) } url = self . _url + "/edit" return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Edits the usage report . To edit a usage report you need to submit the complete JSON representation of the usage report which includes updates to the usage report properties . The name of the report cannot be changed when editing the usage report . | 166 | 46 |
244,978 | def __init ( self ) : params = { "f" : "json" , } json_dict = self . _get ( self . _url , params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _json_dict = json_dict self . _json = json . dumps ( self . _json_dict ) attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k in attributes : if k == "versions" and json_dict [ k ] : self . _versions = [ ] for version in v : self . _versions . append ( Version ( url = self . _url + "/versions/%s" % version , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) elif k == "replicas" and json_dict [ k ] : self . _replicas = [ ] for version in v : self . _replicas . append ( Replica ( url = self . _url + "/replicas/%s" % version , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) else : setattr ( self , "_" + k , v ) else : print ( k , " - attribute not implemented for GeoData Service" ) | inializes the properties | 361 | 5 |
244,979 | def replicasResource ( self ) : if self . _replicasResource is None : self . _replicasResource = { } for replica in self . replicas : self . _replicasResource [ "replicaName" ] = replica . name self . _replicasResource [ "replicaID" ] = replica . guid return self . _replicasResource | returns a list of replices | 76 | 7 |
244,980 | def services ( self ) : self . _services = [ ] params = { "f" : "json" } if not self . _url . endswith ( '/services' ) : uURL = self . _url + "/services" else : uURL = self . _url res = self . _get ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) for k , v in res . items ( ) : if k == "foldersDetail" : for item in v : if 'isDefault' in item and item [ 'isDefault' ] == False : fURL = self . _url + "/services/" + item [ 'folderName' ] resFolder = self . _get ( url = fURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) for k1 , v1 in resFolder . items ( ) : if k1 == "services" : self . _checkservice ( k1 , v1 , fURL ) elif k == "services" : self . _checkservice ( k , v , uURL ) return self . _services | returns all the service objects in the admin service s page | 287 | 12 |
244,981 | def refresh ( self , serviceDefinition = True ) : url = self . _url + "/MapServer/refresh" params = { "f" : "json" , "serviceDefinition" : serviceDefinition } res = self . _post ( url = self . _url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . __init ( ) return res | The refresh operation refreshes a service which clears the web server cache for the service . | 103 | 17 |
244,982 | def editTileService ( self , serviceDefinition = None , minScale = None , maxScale = None , sourceItemId = None , exportTilesAllowed = False , maxExportTileCount = 100000 ) : params = { "f" : "json" , } if not serviceDefinition is None : params [ "serviceDefinition" ] = serviceDefinition if not minScale is None : params [ 'minScale' ] = float ( minScale ) if not maxScale is None : params [ 'maxScale' ] = float ( maxScale ) if not sourceItemId is None : params [ "sourceItemId" ] = sourceItemId if not exportTilesAllowed is None : params [ "exportTilesAllowed" ] = exportTilesAllowed if not maxExportTileCount is None : params [ "maxExportTileCount" ] = int ( maxExportTileCount ) url = self . _url + "/edit" return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _securityHandler . proxy_url , proxy_port = self . _securityHandler . proxy_port ) | This post operation updates a Tile Service s properties | 249 | 9 |
244,983 | def refresh ( self ) : params = { "f" : "json" } uURL = self . _url + "/refresh" res = self . _get ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . __init ( ) return res | refreshes a service | 86 | 5 |
244,984 | def addToDefinition ( self , json_dict ) : params = { "f" : "json" , "addToDefinition" : json . dumps ( json_dict ) , "async" : False } uURL = self . _url + "/addToDefinition" res = self . _post ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . refresh ( ) return res | The addToDefinition operation supports adding a definition property to a hosted feature service . The result of this operation is a response indicating success or failure with error code and description . | 114 | 34 |
244,985 | def updateDefinition ( self , json_dict ) : definition = None if json_dict is not None : if isinstance ( json_dict , collections . OrderedDict ) == True : definition = json_dict else : definition = collections . OrderedDict ( ) if 'hasStaticData' in json_dict : definition [ 'hasStaticData' ] = json_dict [ 'hasStaticData' ] if 'allowGeometryUpdates' in json_dict : definition [ 'allowGeometryUpdates' ] = json_dict [ 'allowGeometryUpdates' ] if 'capabilities' in json_dict : definition [ 'capabilities' ] = json_dict [ 'capabilities' ] if 'editorTrackingInfo' in json_dict : definition [ 'editorTrackingInfo' ] = collections . OrderedDict ( ) if 'enableEditorTracking' in json_dict [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ 'enableEditorTracking' ] = json_dict [ 'editorTrackingInfo' ] [ 'enableEditorTracking' ] if 'enableOwnershipAccessControl' in json_dict [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ 'enableOwnershipAccessControl' ] = json_dict [ 'editorTrackingInfo' ] [ 'enableOwnershipAccessControl' ] if 'allowOthersToUpdate' in json_dict [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ 'allowOthersToUpdate' ] = json_dict [ 'editorTrackingInfo' ] [ 'allowOthersToUpdate' ] if 'allowOthersToDelete' in json_dict [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ 'allowOthersToDelete' ] = json_dict [ 'editorTrackingInfo' ] [ 'allowOthersToDelete' ] if 'allowOthersToQuery' in json_dict [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ 'allowOthersToQuery' ] = json_dict [ 'editorTrackingInfo' ] [ 'allowOthersToQuery' ] if isinstance ( json_dict [ 'editorTrackingInfo' ] , dict ) : for k , v in json_dict [ 'editorTrackingInfo' ] . items ( ) : if k not in definition [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ k ] = v if isinstance ( json_dict , dict ) : for k , v in json_dict . items ( ) : if k not in definition : definition [ k ] = v params = { "f" : "json" , "updateDefinition" : json . dumps ( obj = definition , separators = ( ',' , ':' ) ) , "async" : False } uURL = self . _url + "/updateDefinition" res = self . _post ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . refresh ( ) return res | The updateDefinition operation supports updating a definition property in a hosted feature service . The result of this operation is a response indicating success or failure with error code and description . | 683 | 33 |
244,986 | def calc_resp ( password_hash , server_challenge ) : # padding with zeros to make the hash 21 bytes long password_hash += b'\0' * ( 21 - len ( password_hash ) ) res = b'' dobj = des . DES ( password_hash [ 0 : 7 ] ) res = res + dobj . encrypt ( server_challenge [ 0 : 8 ] ) dobj = des . DES ( password_hash [ 7 : 14 ] ) res = res + dobj . encrypt ( server_challenge [ 0 : 8 ] ) dobj = des . DES ( password_hash [ 14 : 21 ] ) res = res + dobj . encrypt ( server_challenge [ 0 : 8 ] ) return res | calc_resp generates the LM response given a 16 - byte password hash and the challenge from the Type - 2 message . | 158 | 25 |
244,987 | def create_LM_hashed_password_v1 ( passwd ) : # if the passwd provided is already a hash, we just return the first half if re . match ( r'^[\w]{32}:[\w]{32}$' , passwd ) : return binascii . unhexlify ( passwd . split ( ':' ) [ 0 ] ) # fix the password length to 14 bytes passwd = passwd . upper ( ) lm_pw = passwd + '\0' * ( 14 - len ( passwd ) ) lm_pw = passwd [ 0 : 14 ] # do hash magic_str = b"KGS!@#$%" # page 57 in [MS-NLMP] res = b'' dobj = des . DES ( lm_pw [ 0 : 7 ] ) res = res + dobj . encrypt ( magic_str ) dobj = des . DES ( lm_pw [ 7 : 14 ] ) res = res + dobj . encrypt ( magic_str ) return res | create LanManager hashed password | 232 | 6 |
244,988 | def _readcsv ( self , path_to_csv ) : return np . genfromtxt ( path_to_csv , dtype = None , delimiter = ',' , names = True ) | reads a csv column | 42 | 5 |
244,989 | def queryDataCollectionByName ( self , countryName ) : var = self . _dataCollectionCodes try : return [ x [ 0 ] for x in var [ var [ 'Countries' ] == countryName ] ] except : return None | returns a list of available data collections for a given country name . | 51 | 14 |
244,990 | def __geometryToDict ( self , geom ) : if isinstance ( geom , dict ) : return geom elif isinstance ( geom , Point ) : pt = geom . asDictionary return { "geometry" : { "x" : pt [ 'x' ] , "y" : pt [ 'y' ] } } elif isinstance ( geom , Polygon ) : poly = geom . asDictionary return { "geometry" : { "rings" : poly [ 'rings' ] , 'spatialReference' : poly [ 'spatialReference' ] } } elif isinstance ( geom , list ) : return [ self . __geometryToDict ( g ) for g in geom ] | converts a geometry object to a dictionary | 162 | 8 |
244,991 | def lookUpReportsByCountry ( self , countryName ) : code = self . findCountryTwoDigitCode ( countryName ) if code is None : raise Exception ( "Invalid country name." ) url = self . _base_url + self . _url_list_reports + "/%s" % code params = { "f" : "json" , } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | looks up a country by it s name Inputs countryName - name of the country to get reports list . | 124 | 23 |
244,992 | def createReport ( self , out_file_path , studyAreas , report = None , format = "PDF" , reportFields = None , studyAreasOptions = None , useData = None , inSR = 4326 , ) : url = self . _base_url + self . _url_create_report if isinstance ( studyAreas , list ) == False : studyAreas = [ studyAreas ] studyAreas = self . __geometryToDict ( studyAreas ) params = { "f" : "bin" , "studyAreas" : studyAreas , "inSR" : inSR , } if not report is None : params [ 'report' ] = report if format is None : format = "pdf" elif format . lower ( ) in [ 'pdf' , 'xlsx' ] : params [ 'format' ] = format . lower ( ) else : raise AttributeError ( "Invalid format value." ) if not reportFields is None : params [ 'reportFields' ] = reportFields if not studyAreasOptions is None : params [ 'studyAreasOptions' ] = studyAreasOptions if not useData is None : params [ 'useData' ] = useData result = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = os . path . dirname ( out_file_path ) ) return result | The GeoEnrichment Create Report method uses the concept of a study area to define the location of the point or area that you want to enrich with generated reports . This method allows you to create many types of high - quality reports for a variety of use cases describing the input area . If a point is used as a study area the service will create a 1 - mile ring buffer around the point to collect and append enrichment data . Optionally you can create a buffer ring or drive - time service area around the points to prepare PDF or Excel reports for the study areas . | 335 | 114 |
244,993 | def getVariables ( self , sourceCountry , optionalCountryDataset = None , searchText = None ) : url = self . _base_url + self . _url_getVariables params = { "f" : "json" , "sourceCountry" : sourceCountry } if not searchText is None : params [ "searchText" ] = searchText if not optionalCountryDataset is None : params [ 'optionalCountryDataset' ] = optionalCountryDataset return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | r The GeoEnrichment GetVariables helper method allows you to search the data collections for variables that contain specific keywords . | 150 | 25 |
244,994 | def folders ( self ) : if self . _folders is None : self . __init ( ) if "/" not in self . _folders : self . _folders . append ( "/" ) return self . _folders | returns a list of all folders | 49 | 7 |
244,995 | def services ( self ) : self . _services = [ ] params = { "f" : "json" } json_dict = self . _get ( url = self . _currentURL , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) if "services" in json_dict . keys ( ) : for s in json_dict [ 'services' ] : uURL = self . _currentURL + "/%s.%s" % ( s [ 'serviceName' ] , s [ 'type' ] ) self . _services . append ( AGSService ( url = uURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return self . _services | returns the services in the current folder | 190 | 8 |
244,996 | def createService ( self , service ) : url = self . _url + "/createService" params = { "f" : "json" } if isinstance ( service , str ) : params [ 'service' ] = service elif isinstance ( service , dict ) : params [ 'service' ] = json . dumps ( service ) return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Creates a new GIS service in the folder . A service is created by submitting a JSON representation of the service to this operation . | 118 | 27 |
244,997 | def exists ( self , folderName , serviceName = None , serviceType = None ) : url = self . _url + "/exists" params = { "f" : "json" , "folderName" : folderName , "serviceName" : serviceName , "type" : serviceType } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | This operation allows you to check whether a folder or a service exists . To test if a folder exists supply only a folderName . To test if a service exists in a root folder supply both serviceName and serviceType with folderName = None . To test if a service exists in a folder supply all three parameters . | 111 | 63 |
244,998 | def __init ( self ) : params = { "f" : "json" } json_dict = self . _get ( url = self . _currentURL , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _json = json . dumps ( json_dict ) self . _json_dict = json_dict attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k . lower ( ) == "extensions" : self . _extensions = [ ] for ext in v : self . _extensions . append ( Extension . fromJSON ( ext ) ) del ext elif k in attributes : setattr ( self , "_" + k , json_dict [ k ] ) else : print ( k , " - attribute not implemented in manageags.AGSService." ) del k del v | populates server admin information | 239 | 5 |
244,999 | def serviceManifest ( self , fileType = "json" ) : url = self . _url + "/iteminfo/manifest/manifest.%s" % fileType params = { } f = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = tempfile . gettempdir ( ) , file_name = os . path . basename ( url ) ) if fileType == 'json' : return f if fileType == 'xml' : return ET . ElementTree ( ET . fromstring ( f ) ) | The service manifest resource documents the data and other resources that define the service origins and power the service . This resource will tell you underlying databases and their location along with other supplementary files that make up the service . | 149 | 41 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.