repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
PredixDev/predixpy
predix/data/asset.py
Asset.put_collection
def put_collection(self, collection, body): """ Updates an existing collection. The collection being updated *is* expected to include the id. """ uri = self.uri + '/v1' + collection return self.service._put(uri, body)
python
def put_collection(self, collection, body): """ Updates an existing collection. The collection being updated *is* expected to include the id. """ uri = self.uri + '/v1' + collection return self.service._put(uri, body)
[ "def", "put_collection", "(", "self", ",", "collection", ",", "body", ")", ":", "uri", "=", "self", ".", "uri", "+", "'/v1'", "+", "collection", "return", "self", ".", "service", ".", "_put", "(", "uri", ",", "body", ")" ]
Updates an existing collection. The collection being updated *is* expected to include the id.
[ "Updates", "an", "existing", "collection", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/asset.py#L132-L140
train
PredixDev/predixpy
predix/data/asset.py
Asset.delete_collection
def delete_collection(self, collection): """ Deletes an existing collection. The collection being updated *is* expected to include the id. """ uri = str.join('/', [self.uri, collection]) return self.service._delete(uri)
python
def delete_collection(self, collection): """ Deletes an existing collection. The collection being updated *is* expected to include the id. """ uri = str.join('/', [self.uri, collection]) return self.service._delete(uri)
[ "def", "delete_collection", "(", "self", ",", "collection", ")", ":", "uri", "=", "str", ".", "join", "(", "'/'", ",", "[", "self", ".", "uri", ",", "collection", "]", ")", "return", "self", ".", "service", ".", "_delete", "(", "uri", ")" ]
Deletes an existing collection. The collection being updated *is* expected to include the id.
[ "Deletes", "an", "existing", "collection", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/asset.py#L142-L149
train
PredixDev/predixpy
predix/data/asset.py
Asset.patch_collection
def patch_collection(self, collection, changes): """ Will make specific updates to a record based on JSON Patch documentation. https://tools.ietf.org/html/rfc6902 the format of changes is something like:: [{ 'op': 'add', 'path': ...
python
def patch_collection(self, collection, changes): """ Will make specific updates to a record based on JSON Patch documentation. https://tools.ietf.org/html/rfc6902 the format of changes is something like:: [{ 'op': 'add', 'path': ...
[ "def", "patch_collection", "(", "self", ",", "collection", ",", "changes", ")", ":", "uri", "=", "str", ".", "join", "(", "'/'", ",", "[", "self", ".", "uri", ",", "collection", "]", ")", "return", "self", ".", "service", ".", "_patch", "(", "uri", ...
Will make specific updates to a record based on JSON Patch documentation. https://tools.ietf.org/html/rfc6902 the format of changes is something like:: [{ 'op': 'add', 'path': '/newfield', 'value': 'just added' }]
[ "Will", "make", "specific", "updates", "to", "a", "record", "based", "on", "JSON", "Patch", "documentation", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/asset.py#L151-L168
train
PredixDev/predixpy
predix/data/asset.py
Asset.save
def save(self, collection): """ Save an asset collection to the service. """ assert isinstance(collection, predix.data.asset.AssetCollection), "Expected AssetCollection" collection.validate() self.put_collection(collection.uri, collection.__dict__)
python
def save(self, collection): """ Save an asset collection to the service. """ assert isinstance(collection, predix.data.asset.AssetCollection), "Expected AssetCollection" collection.validate() self.put_collection(collection.uri, collection.__dict__)
[ "def", "save", "(", "self", ",", "collection", ")", ":", "assert", "isinstance", "(", "collection", ",", "predix", ".", "data", ".", "asset", ".", "AssetCollection", ")", ",", "\"Expected AssetCollection\"", "collection", ".", "validate", "(", ")", "self", "...
Save an asset collection to the service.
[ "Save", "an", "asset", "collection", "to", "the", "service", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/asset.py#L212-L218
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_manifest_from_space
def create_manifest_from_space(self): """ Populate a manifest file generated from details from the cloud foundry space environment. """ space = predix.admin.cf.spaces.Space() summary = space.get_space_summary() for instance in summary['services']: ser...
python
def create_manifest_from_space(self): """ Populate a manifest file generated from details from the cloud foundry space environment. """ space = predix.admin.cf.spaces.Space() summary = space.get_space_summary() for instance in summary['services']: ser...
[ "def", "create_manifest_from_space", "(", "self", ")", ":", "space", "=", "predix", ".", "admin", ".", "cf", ".", "spaces", ".", "Space", "(", ")", "summary", "=", "space", ".", "get_space_summary", "(", ")", "for", "instance", "in", "summary", "[", "'se...
Populate a manifest file generated from details from the cloud foundry space environment.
[ "Populate", "a", "manifest", "file", "generated", "from", "details", "from", "the", "cloud", "foundry", "space", "environment", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L40-L58
train
PredixDev/predixpy
predix/admin/app.py
Manifest.lock_to_org_space
def lock_to_org_space(self): """ Lock the manifest to the current organization and space regardless of Cloud Foundry target. """ self.add_env_var('PREDIX_ORGANIZATION_GUID', self.space.org.guid) self.add_env_var('PREDIX_ORGANIZATION_NAME', self.space.org.name) sel...
python
def lock_to_org_space(self): """ Lock the manifest to the current organization and space regardless of Cloud Foundry target. """ self.add_env_var('PREDIX_ORGANIZATION_GUID', self.space.org.guid) self.add_env_var('PREDIX_ORGANIZATION_NAME', self.space.org.name) sel...
[ "def", "lock_to_org_space", "(", "self", ")", ":", "self", ".", "add_env_var", "(", "'PREDIX_ORGANIZATION_GUID'", ",", "self", ".", "space", ".", "org", ".", "guid", ")", "self", ".", "add_env_var", "(", "'PREDIX_ORGANIZATION_NAME'", ",", "self", ".", "space",...
Lock the manifest to the current organization and space regardless of Cloud Foundry target.
[ "Lock", "the", "manifest", "to", "the", "current", "organization", "and", "space", "regardless", "of", "Cloud", "Foundry", "target", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L60-L69
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_uaa
def create_uaa(self, admin_secret, **kwargs): """ Creates an instance of UAA Service. :param admin_secret: The secret password for administering the service such as adding clients and users. """ uaa = predix.admin.uaa.UserAccountAuthentication(**kwargs) if no...
python
def create_uaa(self, admin_secret, **kwargs): """ Creates an instance of UAA Service. :param admin_secret: The secret password for administering the service such as adding clients and users. """ uaa = predix.admin.uaa.UserAccountAuthentication(**kwargs) if no...
[ "def", "create_uaa", "(", "self", ",", "admin_secret", ",", "*", "*", "kwargs", ")", ":", "uaa", "=", "predix", ".", "admin", ".", "uaa", ".", "UserAccountAuthentication", "(", "*", "*", "kwargs", ")", "if", "not", "uaa", ".", "exists", "(", ")", ":"...
Creates an instance of UAA Service. :param admin_secret: The secret password for administering the service such as adding clients and users.
[ "Creates", "an", "instance", "of", "UAA", "Service", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L71-L83
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_client
def create_client(self, client_id=None, client_secret=None, uaa=None): """ Create a client and add it to the manifest. :param client_id: The client id used to authenticate as a client in UAA. :param client_secret: The secret password used by a client to authenti...
python
def create_client(self, client_id=None, client_secret=None, uaa=None): """ Create a client and add it to the manifest. :param client_id: The client id used to authenticate as a client in UAA. :param client_secret: The secret password used by a client to authenti...
[ "def", "create_client", "(", "self", ",", "client_id", "=", "None", ",", "client_secret", "=", "None", ",", "uaa", "=", "None", ")", ":", "if", "not", "uaa", ":", "uaa", "=", "predix", ".", "admin", ".", "uaa", ".", "UserAccountAuthentication", "(", ")...
Create a client and add it to the manifest. :param client_id: The client id used to authenticate as a client in UAA. :param client_secret: The secret password used by a client to authenticate and generate a UAA token. :param uaa: The UAA to create client with
[ "Create", "a", "client", "and", "add", "it", "to", "the", "manifest", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L85-L109
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_timeseries
def create_timeseries(self, **kwargs): """ Creates an instance of the Time Series Service. """ ts = predix.admin.timeseries.TimeSeries(**kwargs) ts.create() client_id = self.get_client_id() if client_id: ts.grant_client(client_id) ts.add_to_m...
python
def create_timeseries(self, **kwargs): """ Creates an instance of the Time Series Service. """ ts = predix.admin.timeseries.TimeSeries(**kwargs) ts.create() client_id = self.get_client_id() if client_id: ts.grant_client(client_id) ts.add_to_m...
[ "def", "create_timeseries", "(", "self", ",", "*", "*", "kwargs", ")", ":", "ts", "=", "predix", ".", "admin", ".", "timeseries", ".", "TimeSeries", "(", "*", "*", "kwargs", ")", "ts", ".", "create", "(", ")", "client_id", "=", "self", ".", "get_clie...
Creates an instance of the Time Series Service.
[ "Creates", "an", "instance", "of", "the", "Time", "Series", "Service", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L111-L123
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_asset
def create_asset(self, **kwargs): """ Creates an instance of the Asset Service. """ asset = predix.admin.asset.Asset(**kwargs) asset.create() client_id = self.get_client_id() if client_id: asset.grant_client(client_id) asset.add_to_manifest(s...
python
def create_asset(self, **kwargs): """ Creates an instance of the Asset Service. """ asset = predix.admin.asset.Asset(**kwargs) asset.create() client_id = self.get_client_id() if client_id: asset.grant_client(client_id) asset.add_to_manifest(s...
[ "def", "create_asset", "(", "self", ",", "*", "*", "kwargs", ")", ":", "asset", "=", "predix", ".", "admin", ".", "asset", ".", "Asset", "(", "*", "*", "kwargs", ")", "asset", ".", "create", "(", ")", "client_id", "=", "self", ".", "get_client_id", ...
Creates an instance of the Asset Service.
[ "Creates", "an", "instance", "of", "the", "Asset", "Service", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L125-L137
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_acs
def create_acs(self, **kwargs): """ Creates an instance of the Asset Service. """ acs = predix.admin.acs.AccessControl(**kwargs) acs.create() client_id = self.get_client_id() if client_id: acs.grant_client(client_id) acs.grant_client(client_i...
python
def create_acs(self, **kwargs): """ Creates an instance of the Asset Service. """ acs = predix.admin.acs.AccessControl(**kwargs) acs.create() client_id = self.get_client_id() if client_id: acs.grant_client(client_id) acs.grant_client(client_i...
[ "def", "create_acs", "(", "self", ",", "*", "*", "kwargs", ")", ":", "acs", "=", "predix", ".", "admin", ".", "acs", ".", "AccessControl", "(", "*", "*", "kwargs", ")", "acs", ".", "create", "(", ")", "client_id", "=", "self", ".", "get_client_id", ...
Creates an instance of the Asset Service.
[ "Creates", "an", "instance", "of", "the", "Asset", "Service", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L139-L152
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_weather
def create_weather(self, **kwargs): """ Creates an instance of the Asset Service. """ weather = predix.admin.weather.WeatherForecast(**kwargs) weather.create() client_id = self.get_client_id() if client_id: weather.grant_client(client_id) wea...
python
def create_weather(self, **kwargs): """ Creates an instance of the Asset Service. """ weather = predix.admin.weather.WeatherForecast(**kwargs) weather.create() client_id = self.get_client_id() if client_id: weather.grant_client(client_id) wea...
[ "def", "create_weather", "(", "self", ",", "*", "*", "kwargs", ")", ":", "weather", "=", "predix", ".", "admin", ".", "weather", ".", "WeatherForecast", "(", "*", "*", "kwargs", ")", "weather", ".", "create", "(", ")", "client_id", "=", "self", ".", ...
Creates an instance of the Asset Service.
[ "Creates", "an", "instance", "of", "the", "Asset", "Service", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L154-L167
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_blobstore
def create_blobstore(self, **kwargs): """ Creates an instance of the BlobStore Service. """ blobstore = predix.admin.blobstore.BlobStore(**kwargs) blobstore.create() blobstore.add_to_manifest(self) return blobstore
python
def create_blobstore(self, **kwargs): """ Creates an instance of the BlobStore Service. """ blobstore = predix.admin.blobstore.BlobStore(**kwargs) blobstore.create() blobstore.add_to_manifest(self) return blobstore
[ "def", "create_blobstore", "(", "self", ",", "*", "*", "kwargs", ")", ":", "blobstore", "=", "predix", ".", "admin", ".", "blobstore", ".", "BlobStore", "(", "*", "*", "kwargs", ")", "blobstore", ".", "create", "(", ")", "blobstore", ".", "add_to_manifes...
Creates an instance of the BlobStore Service.
[ "Creates", "an", "instance", "of", "the", "BlobStore", "Service", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L169-L177
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_logstash
def create_logstash(self, **kwargs): """ Creates an instance of the Logging Service. """ logstash = predix.admin.logstash.Logging(**kwargs) logstash.create() logstash.add_to_manifest(self) logging.info('Install Kibana-Me-Logs application by following GitHub instr...
python
def create_logstash(self, **kwargs): """ Creates an instance of the Logging Service. """ logstash = predix.admin.logstash.Logging(**kwargs) logstash.create() logstash.add_to_manifest(self) logging.info('Install Kibana-Me-Logs application by following GitHub instr...
[ "def", "create_logstash", "(", "self", ",", "*", "*", "kwargs", ")", ":", "logstash", "=", "predix", ".", "admin", ".", "logstash", ".", "Logging", "(", "*", "*", "kwargs", ")", "logstash", ".", "create", "(", ")", "logstash", ".", "add_to_manifest", "...
Creates an instance of the Logging Service.
[ "Creates", "an", "instance", "of", "the", "Logging", "Service", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L179-L190
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_cache
def create_cache(self, **kwargs): """ Creates an instance of the Cache Service. """ cache = predix.admin.cache.Cache(**kwargs) cache.create(**kwargs) cache.add_to_manifest(self) return cache
python
def create_cache(self, **kwargs): """ Creates an instance of the Cache Service. """ cache = predix.admin.cache.Cache(**kwargs) cache.create(**kwargs) cache.add_to_manifest(self) return cache
[ "def", "create_cache", "(", "self", ",", "*", "*", "kwargs", ")", ":", "cache", "=", "predix", ".", "admin", ".", "cache", ".", "Cache", "(", "*", "*", "kwargs", ")", "cache", ".", "create", "(", "*", "*", "kwargs", ")", "cache", ".", "add_to_manif...
Creates an instance of the Cache Service.
[ "Creates", "an", "instance", "of", "the", "Cache", "Service", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L192-L199
train
PredixDev/predixpy
predix/admin/app.py
Manifest.create_eventhub
def create_eventhub(self, **kwargs): """ todo make it so the client can be customised to publish/subscribe Creates an instance of eventhub service """ eventhub = predix.admin.eventhub.EventHub(**kwargs) eventhub.create() eventhub.add_to_manifest(self) even...
python
def create_eventhub(self, **kwargs): """ todo make it so the client can be customised to publish/subscribe Creates an instance of eventhub service """ eventhub = predix.admin.eventhub.EventHub(**kwargs) eventhub.create() eventhub.add_to_manifest(self) even...
[ "def", "create_eventhub", "(", "self", ",", "*", "*", "kwargs", ")", ":", "eventhub", "=", "predix", ".", "admin", ".", "eventhub", ".", "EventHub", "(", "*", "*", "kwargs", ")", "eventhub", ".", "create", "(", ")", "eventhub", ".", "add_to_manifest", ...
todo make it so the client can be customised to publish/subscribe Creates an instance of eventhub service
[ "todo", "make", "it", "so", "the", "client", "can", "be", "customised", "to", "publish", "/", "subscribe", "Creates", "an", "instance", "of", "eventhub", "service" ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L209-L219
train
PredixDev/predixpy
predix/admin/app.py
Manifest.get_service_marketplace
def get_service_marketplace(self, available=True, unavailable=False, deprecated=False): """ Returns a list of service names. Can return all services, just those supported by PredixPy, or just those not yet supported by PredixPy. :param available: Return the services...
python
def get_service_marketplace(self, available=True, unavailable=False, deprecated=False): """ Returns a list of service names. Can return all services, just those supported by PredixPy, or just those not yet supported by PredixPy. :param available: Return the services...
[ "def", "get_service_marketplace", "(", "self", ",", "available", "=", "True", ",", "unavailable", "=", "False", ",", "deprecated", "=", "False", ")", ":", "supported", "=", "set", "(", "self", ".", "supported", ".", "keys", "(", ")", ")", "all_services", ...
Returns a list of service names. Can return all services, just those supported by PredixPy, or just those not yet supported by PredixPy. :param available: Return the services that are available in PredixPy. (Defaults to True) :param unavailable: Return the services that a...
[ "Returns", "a", "list", "of", "service", "names", ".", "Can", "return", "all", "services", "just", "those", "supported", "by", "PredixPy", "or", "just", "those", "not", "yet", "supported", "by", "PredixPy", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/app.py#L222-L250
train
PredixDev/predixpy
predix/service.py
Service._auto_authenticate
def _auto_authenticate(self): """ If we are in an app context we can authenticate immediately. """ client_id = predix.config.get_env_value(predix.app.Manifest, 'client_id') client_secret = predix.config.get_env_value(predix.app.Manifest, 'client_secret') if client_id and...
python
def _auto_authenticate(self): """ If we are in an app context we can authenticate immediately. """ client_id = predix.config.get_env_value(predix.app.Manifest, 'client_id') client_secret = predix.config.get_env_value(predix.app.Manifest, 'client_secret') if client_id and...
[ "def", "_auto_authenticate", "(", "self", ")", ":", "client_id", "=", "predix", ".", "config", ".", "get_env_value", "(", "predix", ".", "app", ".", "Manifest", ",", "'client_id'", ")", "client_secret", "=", "predix", ".", "config", ".", "get_env_value", "("...
If we are in an app context we can authenticate immediately.
[ "If", "we", "are", "in", "an", "app", "context", "we", "can", "authenticate", "immediately", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/service.py#L29-L38
train
PredixDev/predixpy
predix/service.py
Service._get
def _get(self, uri, params=None, headers=None): """ Simple GET request for a given path. """ if not headers: headers = self._get_headers() logging.debug("URI=" + str(uri)) logging.debug("HEADERS=" + str(headers)) response = self.session.get(uri, head...
python
def _get(self, uri, params=None, headers=None): """ Simple GET request for a given path. """ if not headers: headers = self._get_headers() logging.debug("URI=" + str(uri)) logging.debug("HEADERS=" + str(headers)) response = self.session.get(uri, head...
[ "def", "_get", "(", "self", ",", "uri", ",", "params", "=", "None", ",", "headers", "=", "None", ")", ":", "if", "not", "headers", ":", "headers", "=", "self", ".", "_get_headers", "(", ")", "logging", ".", "debug", "(", "\"URI=\"", "+", "str", "("...
Simple GET request for a given path.
[ "Simple", "GET", "request", "for", "a", "given", "path", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/service.py#L58-L74
train
PredixDev/predixpy
predix/service.py
Service._post
def _post(self, uri, data): """ Simple POST request for a given path. """ headers = self._get_headers() logging.debug("URI=" + str(uri)) logging.debug("BODY=" + json.dumps(data)) response = self.session.post(uri, headers=headers, data=json.dumps(...
python
def _post(self, uri, data): """ Simple POST request for a given path. """ headers = self._get_headers() logging.debug("URI=" + str(uri)) logging.debug("BODY=" + json.dumps(data)) response = self.session.post(uri, headers=headers, data=json.dumps(...
[ "def", "_post", "(", "self", ",", "uri", ",", "data", ")", ":", "headers", "=", "self", ".", "_get_headers", "(", ")", "logging", ".", "debug", "(", "\"URI=\"", "+", "str", "(", "uri", ")", ")", "logging", ".", "debug", "(", "\"BODY=\"", "+", "json...
Simple POST request for a given path.
[ "Simple", "POST", "request", "for", "a", "given", "path", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/service.py#L76-L94
train
PredixDev/predixpy
predix/service.py
Service._put
def _put(self, uri, data): """ Simple PUT operation for a given path. """ headers = self._get_headers() logging.debug("URI=" + str(uri)) logging.debug("BODY=" + json.dumps(data)) response = self.session.put(uri, headers=headers, data=json.dumps(d...
python
def _put(self, uri, data): """ Simple PUT operation for a given path. """ headers = self._get_headers() logging.debug("URI=" + str(uri)) logging.debug("BODY=" + json.dumps(data)) response = self.session.put(uri, headers=headers, data=json.dumps(d...
[ "def", "_put", "(", "self", ",", "uri", ",", "data", ")", ":", "headers", "=", "self", ".", "_get_headers", "(", ")", "logging", ".", "debug", "(", "\"URI=\"", "+", "str", "(", "uri", ")", ")", "logging", ".", "debug", "(", "\"BODY=\"", "+", "json"...
Simple PUT operation for a given path.
[ "Simple", "PUT", "operation", "for", "a", "given", "path", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/service.py#L96-L111
train
PredixDev/predixpy
predix/service.py
Service._delete
def _delete(self, uri): """ Simple DELETE operation for a given path. """ headers = self._get_headers() response = self.session.delete(uri, headers=headers) # Will return a 204 on successful delete if response.status_code == 204: return response ...
python
def _delete(self, uri): """ Simple DELETE operation for a given path. """ headers = self._get_headers() response = self.session.delete(uri, headers=headers) # Will return a 204 on successful delete if response.status_code == 204: return response ...
[ "def", "_delete", "(", "self", ",", "uri", ")", ":", "headers", "=", "self", ".", "_get_headers", "(", ")", "response", "=", "self", ".", "session", ".", "delete", "(", "uri", ",", "headers", "=", "headers", ")", "# Will return a 204 on successful delete", ...
Simple DELETE operation for a given path.
[ "Simple", "DELETE", "operation", "for", "a", "given", "path", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/service.py#L113-L126
train
PredixDev/predixpy
predix/service.py
Service._patch
def _patch(self, uri, data): """ Simple PATCH operation for a given path. The body is expected to list operations to perform to update the data. Operations include: - add - remove - replace - move - copy - test ...
python
def _patch(self, uri, data): """ Simple PATCH operation for a given path. The body is expected to list operations to perform to update the data. Operations include: - add - remove - replace - move - copy - test ...
[ "def", "_patch", "(", "self", ",", "uri", ",", "data", ")", ":", "headers", "=", "self", ".", "_get_headers", "(", ")", "response", "=", "self", ".", "session", ".", "patch", "(", "uri", ",", "headers", "=", "headers", ",", "data", "=", "json", "."...
Simple PATCH operation for a given path. The body is expected to list operations to perform to update the data. Operations include: - add - remove - replace - move - copy - test [ { "op": "test", "path": "/a/...
[ "Simple", "PATCH", "operation", "for", "a", "given", "path", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/service.py#L128-L154
train
PredixDev/predixpy
predix/security/acs.py
AccessControl._get_resource_uri
def _get_resource_uri(self, guid=None): """ Returns the full path that uniquely identifies the resource endpoint. """ uri = self.uri + '/v1/resource' if guid: uri += '/' + urllib.quote_plus(guid) return uri
python
def _get_resource_uri(self, guid=None): """ Returns the full path that uniquely identifies the resource endpoint. """ uri = self.uri + '/v1/resource' if guid: uri += '/' + urllib.quote_plus(guid) return uri
[ "def", "_get_resource_uri", "(", "self", ",", "guid", "=", "None", ")", ":", "uri", "=", "self", ".", "uri", "+", "'/v1/resource'", "if", "guid", ":", "uri", "+=", "'/'", "+", "urllib", ".", "quote_plus", "(", "guid", ")", "return", "uri" ]
Returns the full path that uniquely identifies the resource endpoint.
[ "Returns", "the", "full", "path", "that", "uniquely", "identifies", "the", "resource", "endpoint", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L64-L72
train
PredixDev/predixpy
predix/security/acs.py
AccessControl.get_resource
def get_resource(self, resource_id): """ Returns a specific resource by resource id. """ # resource_id could be a path such as '/asset/123' so quote uri = self._get_resource_uri(guid=resource_id) return self.service._get(uri)
python
def get_resource(self, resource_id): """ Returns a specific resource by resource id. """ # resource_id could be a path such as '/asset/123' so quote uri = self._get_resource_uri(guid=resource_id) return self.service._get(uri)
[ "def", "get_resource", "(", "self", ",", "resource_id", ")", ":", "# resource_id could be a path such as '/asset/123' so quote", "uri", "=", "self", ".", "_get_resource_uri", "(", "guid", "=", "resource_id", ")", "return", "self", ".", "service", ".", "_get", "(", ...
Returns a specific resource by resource id.
[ "Returns", "a", "specific", "resource", "by", "resource", "id", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L81-L87
train
PredixDev/predixpy
predix/security/acs.py
AccessControl._post_resource
def _post_resource(self, body): """ Create new resources and associated attributes. Example: acs.post_resource([ { "resourceIdentifier": "masaya", "parents": [], "attributes": [ { ...
python
def _post_resource(self, body): """ Create new resources and associated attributes. Example: acs.post_resource([ { "resourceIdentifier": "masaya", "parents": [], "attributes": [ { ...
[ "def", "_post_resource", "(", "self", ",", "body", ")", ":", "assert", "isinstance", "(", "body", ",", "(", "list", ")", ")", ",", "\"POST for requires body to be a list\"", "uri", "=", "self", ".", "_get_resource_uri", "(", ")", "return", "self", ".", "serv...
Create new resources and associated attributes. Example: acs.post_resource([ { "resourceIdentifier": "masaya", "parents": [], "attributes": [ { "issuer": "default", ...
[ "Create", "new", "resources", "and", "associated", "attributes", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L89-L117
train
PredixDev/predixpy
predix/security/acs.py
AccessControl.delete_resource
def delete_resource(self, resource_id): """ Remove a specific resource by its identifier. """ # resource_id could be a path such as '/asset/123' so quote uri = self._get_resource_uri(guid=resource_id) return self.service._delete(uri)
python
def delete_resource(self, resource_id): """ Remove a specific resource by its identifier. """ # resource_id could be a path such as '/asset/123' so quote uri = self._get_resource_uri(guid=resource_id) return self.service._delete(uri)
[ "def", "delete_resource", "(", "self", ",", "resource_id", ")", ":", "# resource_id could be a path such as '/asset/123' so quote", "uri", "=", "self", ".", "_get_resource_uri", "(", "guid", "=", "resource_id", ")", "return", "self", ".", "service", ".", "_delete", ...
Remove a specific resource by its identifier.
[ "Remove", "a", "specific", "resource", "by", "its", "identifier", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L119-L125
train
PredixDev/predixpy
predix/security/acs.py
AccessControl._put_resource
def _put_resource(self, resource_id, body): """ Update a resource for the given resource id. The body is not a list but a dictionary of a single resource. """ assert isinstance(body, (dict)), "PUT requires body to be a dict." # resource_id could be a path such as '/asset...
python
def _put_resource(self, resource_id, body): """ Update a resource for the given resource id. The body is not a list but a dictionary of a single resource. """ assert isinstance(body, (dict)), "PUT requires body to be a dict." # resource_id could be a path such as '/asset...
[ "def", "_put_resource", "(", "self", ",", "resource_id", ",", "body", ")", ":", "assert", "isinstance", "(", "body", ",", "(", "dict", ")", ")", ",", "\"PUT requires body to be a dict.\"", "# resource_id could be a path such as '/asset/123' so quote", "uri", "=", "sel...
Update a resource for the given resource id. The body is not a list but a dictionary of a single resource.
[ "Update", "a", "resource", "for", "the", "given", "resource", "id", ".", "The", "body", "is", "not", "a", "list", "but", "a", "dictionary", "of", "a", "single", "resource", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L127-L135
train
PredixDev/predixpy
predix/security/acs.py
AccessControl.add_resource
def add_resource(self, resource_id, attributes, parents=[], issuer='default'): """ Will add the given resource with a given identifier and attribute dictionary. example/ add_resource('/asset/12', {'id': 12, 'manufacturer': 'GE'}) """ # MA...
python
def add_resource(self, resource_id, attributes, parents=[], issuer='default'): """ Will add the given resource with a given identifier and attribute dictionary. example/ add_resource('/asset/12', {'id': 12, 'manufacturer': 'GE'}) """ # MA...
[ "def", "add_resource", "(", "self", ",", "resource_id", ",", "attributes", ",", "parents", "=", "[", "]", ",", "issuer", "=", "'default'", ")", ":", "# MAINT: consider test to avoid adding duplicate resource id", "assert", "isinstance", "(", "attributes", ",", "(", ...
Will add the given resource with a given identifier and attribute dictionary. example/ add_resource('/asset/12', {'id': 12, 'manufacturer': 'GE'})
[ "Will", "add", "the", "given", "resource", "with", "a", "given", "identifier", "and", "attribute", "dictionary", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L137-L164
train
PredixDev/predixpy
predix/security/acs.py
AccessControl._get_subject_uri
def _get_subject_uri(self, guid=None): """ Returns the full path that uniquely identifies the subject endpoint. """ uri = self.uri + '/v1/subject' if guid: uri += '/' + urllib.quote_plus(guid) return uri
python
def _get_subject_uri(self, guid=None): """ Returns the full path that uniquely identifies the subject endpoint. """ uri = self.uri + '/v1/subject' if guid: uri += '/' + urllib.quote_plus(guid) return uri
[ "def", "_get_subject_uri", "(", "self", ",", "guid", "=", "None", ")", ":", "uri", "=", "self", ".", "uri", "+", "'/v1/subject'", "if", "guid", ":", "uri", "+=", "'/'", "+", "urllib", ".", "quote_plus", "(", "guid", ")", "return", "uri" ]
Returns the full path that uniquely identifies the subject endpoint.
[ "Returns", "the", "full", "path", "that", "uniquely", "identifies", "the", "subject", "endpoint", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L166-L174
train
PredixDev/predixpy
predix/security/acs.py
AccessControl.get_subject
def get_subject(self, subject_id): """ Returns a specific subject by subject id. """ # subject_id could be a path such as '/user/j12y' so quote uri = self._get_subject_uri(guid=subject_id) return self.service._get(uri)
python
def get_subject(self, subject_id): """ Returns a specific subject by subject id. """ # subject_id could be a path such as '/user/j12y' so quote uri = self._get_subject_uri(guid=subject_id) return self.service._get(uri)
[ "def", "get_subject", "(", "self", ",", "subject_id", ")", ":", "# subject_id could be a path such as '/user/j12y' so quote", "uri", "=", "self", ".", "_get_subject_uri", "(", "guid", "=", "subject_id", ")", "return", "self", ".", "service", ".", "_get", "(", "uri...
Returns a specific subject by subject id.
[ "Returns", "a", "specific", "subject", "by", "subject", "id", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L183-L189
train
PredixDev/predixpy
predix/security/acs.py
AccessControl._post_subject
def _post_subject(self, body): """ Create new subjects and associated attributes. Example: acs.post_subject([ { "subjectIdentifier": "/role/evangelist", "parents": [], "attributes": [ ...
python
def _post_subject(self, body): """ Create new subjects and associated attributes. Example: acs.post_subject([ { "subjectIdentifier": "/role/evangelist", "parents": [], "attributes": [ ...
[ "def", "_post_subject", "(", "self", ",", "body", ")", ":", "assert", "isinstance", "(", "body", ",", "(", "list", ")", ")", ",", "\"POST requires body to be a list\"", "uri", "=", "self", ".", "_get_subject_uri", "(", ")", "return", "self", ".", "service", ...
Create new subjects and associated attributes. Example: acs.post_subject([ { "subjectIdentifier": "/role/evangelist", "parents": [], "attributes": [ { "issuer": "default"...
[ "Create", "new", "subjects", "and", "associated", "attributes", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L191-L220
train
PredixDev/predixpy
predix/security/acs.py
AccessControl.delete_subject
def delete_subject(self, subject_id): """ Remove a specific subject by its identifier. """ # subject_id could be a path such as '/role/analyst' so quote uri = self._get_subject_uri(guid=subject_id) return self.service._delete(uri)
python
def delete_subject(self, subject_id): """ Remove a specific subject by its identifier. """ # subject_id could be a path such as '/role/analyst' so quote uri = self._get_subject_uri(guid=subject_id) return self.service._delete(uri)
[ "def", "delete_subject", "(", "self", ",", "subject_id", ")", ":", "# subject_id could be a path such as '/role/analyst' so quote", "uri", "=", "self", ".", "_get_subject_uri", "(", "guid", "=", "subject_id", ")", "return", "self", ".", "service", ".", "_delete", "(...
Remove a specific subject by its identifier.
[ "Remove", "a", "specific", "subject", "by", "its", "identifier", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L222-L228
train
PredixDev/predixpy
predix/security/acs.py
AccessControl._put_subject
def _put_subject(self, subject_id, body): """ Update a subject for the given subject id. The body is not a list but a dictionary of a single resource. """ assert isinstance(body, (dict)), "PUT requires body to be dict." # subject_id could be a path such as '/asset/123' ...
python
def _put_subject(self, subject_id, body): """ Update a subject for the given subject id. The body is not a list but a dictionary of a single resource. """ assert isinstance(body, (dict)), "PUT requires body to be dict." # subject_id could be a path such as '/asset/123' ...
[ "def", "_put_subject", "(", "self", ",", "subject_id", ",", "body", ")", ":", "assert", "isinstance", "(", "body", ",", "(", "dict", ")", ")", ",", "\"PUT requires body to be dict.\"", "# subject_id could be a path such as '/asset/123' so quote", "uri", "=", "self", ...
Update a subject for the given subject id. The body is not a list but a dictionary of a single resource.
[ "Update", "a", "subject", "for", "the", "given", "subject", "id", ".", "The", "body", "is", "not", "a", "list", "but", "a", "dictionary", "of", "a", "single", "resource", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L230-L239
train
PredixDev/predixpy
predix/security/acs.py
AccessControl.add_subject
def add_subject(self, subject_id, attributes, parents=[], issuer='default'): """ Will add the given subject with a given identifier and attribute dictionary. example/ add_subject('/user/j12y', {'username': 'j12y'}) """ # MAINT: consider t...
python
def add_subject(self, subject_id, attributes, parents=[], issuer='default'): """ Will add the given subject with a given identifier and attribute dictionary. example/ add_subject('/user/j12y', {'username': 'j12y'}) """ # MAINT: consider t...
[ "def", "add_subject", "(", "self", ",", "subject_id", ",", "attributes", ",", "parents", "=", "[", "]", ",", "issuer", "=", "'default'", ")", ":", "# MAINT: consider test to avoid adding duplicate subject id", "assert", "isinstance", "(", "attributes", ",", "(", "...
Will add the given subject with a given identifier and attribute dictionary. example/ add_subject('/user/j12y', {'username': 'j12y'})
[ "Will", "add", "the", "given", "subject", "with", "a", "given", "identifier", "and", "attribute", "dictionary", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L241-L268
train
PredixDev/predixpy
predix/security/acs.py
AccessControl._get_monitoring_heartbeat
def _get_monitoring_heartbeat(self): """ Tests whether or not the ACS service being monitored is alive. """ target = self.uri + '/monitoring/heartbeat' response = self.session.get(target) return response
python
def _get_monitoring_heartbeat(self): """ Tests whether or not the ACS service being monitored is alive. """ target = self.uri + '/monitoring/heartbeat' response = self.session.get(target) return response
[ "def", "_get_monitoring_heartbeat", "(", "self", ")", ":", "target", "=", "self", ".", "uri", "+", "'/monitoring/heartbeat'", "response", "=", "self", ".", "session", ".", "get", "(", "target", ")", "return", "response" ]
Tests whether or not the ACS service being monitored is alive.
[ "Tests", "whether", "or", "not", "the", "ACS", "service", "being", "monitored", "is", "alive", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L270-L276
train
PredixDev/predixpy
predix/security/acs.py
AccessControl.is_alive
def is_alive(self): """ Will test whether the ACS service is up and alive. """ response = self.get_monitoring_heartbeat() if response.status_code == 200 and response.content == 'alive': return True return False
python
def is_alive(self): """ Will test whether the ACS service is up and alive. """ response = self.get_monitoring_heartbeat() if response.status_code == 200 and response.content == 'alive': return True return False
[ "def", "is_alive", "(", "self", ")", ":", "response", "=", "self", ".", "get_monitoring_heartbeat", "(", ")", "if", "response", ".", "status_code", "==", "200", "and", "response", ".", "content", "==", "'alive'", ":", "return", "True", "return", "False" ]
Will test whether the ACS service is up and alive.
[ "Will", "test", "whether", "the", "ACS", "service", "is", "up", "and", "alive", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L278-L286
train
PredixDev/predixpy
predix/security/acs.py
AccessControl._get_policy_set_uri
def _get_policy_set_uri(self, guid=None): """ Returns the full path that uniquely identifies the subject endpoint. """ uri = self.uri + '/v1/policy-set' if guid: uri += '/' + urllib.quote_plus(guid) return uri
python
def _get_policy_set_uri(self, guid=None): """ Returns the full path that uniquely identifies the subject endpoint. """ uri = self.uri + '/v1/policy-set' if guid: uri += '/' + urllib.quote_plus(guid) return uri
[ "def", "_get_policy_set_uri", "(", "self", ",", "guid", "=", "None", ")", ":", "uri", "=", "self", ".", "uri", "+", "'/v1/policy-set'", "if", "guid", ":", "uri", "+=", "'/'", "+", "urllib", ".", "quote_plus", "(", "guid", ")", "return", "uri" ]
Returns the full path that uniquely identifies the subject endpoint.
[ "Returns", "the", "full", "path", "that", "uniquely", "identifies", "the", "subject", "endpoint", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L288-L296
train
PredixDev/predixpy
predix/security/acs.py
AccessControl._put_policy_set
def _put_policy_set(self, policy_set_id, body): """ Will create or update a policy set for the given path. """ assert isinstance(body, (dict)), "PUT requires body to be a dict." uri = self._get_policy_set_uri(guid=policy_set_id) return self.service._put(uri, body)
python
def _put_policy_set(self, policy_set_id, body): """ Will create or update a policy set for the given path. """ assert isinstance(body, (dict)), "PUT requires body to be a dict." uri = self._get_policy_set_uri(guid=policy_set_id) return self.service._put(uri, body)
[ "def", "_put_policy_set", "(", "self", ",", "policy_set_id", ",", "body", ")", ":", "assert", "isinstance", "(", "body", ",", "(", "dict", ")", ")", ",", "\"PUT requires body to be a dict.\"", "uri", "=", "self", ".", "_get_policy_set_uri", "(", "guid", "=", ...
Will create or update a policy set for the given path.
[ "Will", "create", "or", "update", "a", "policy", "set", "for", "the", "given", "path", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L305-L311
train
PredixDev/predixpy
predix/security/acs.py
AccessControl._get_policy_set
def _get_policy_set(self, policy_set_id): """ Get a specific policy set by id. """ uri = self._get_policy_set_uri(guid=policy_set_id) return self.service._get(uri)
python
def _get_policy_set(self, policy_set_id): """ Get a specific policy set by id. """ uri = self._get_policy_set_uri(guid=policy_set_id) return self.service._get(uri)
[ "def", "_get_policy_set", "(", "self", ",", "policy_set_id", ")", ":", "uri", "=", "self", ".", "_get_policy_set_uri", "(", "guid", "=", "policy_set_id", ")", "return", "self", ".", "service", ".", "_get", "(", "uri", ")" ]
Get a specific policy set by id.
[ "Get", "a", "specific", "policy", "set", "by", "id", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L313-L318
train
PredixDev/predixpy
predix/security/acs.py
AccessControl.delete_policy_set
def delete_policy_set(self, policy_set_id): """ Delete a specific policy set by id. Method is idempotent. """ uri = self._get_policy_set_uri(guid=policy_set_id) return self.service._delete(uri)
python
def delete_policy_set(self, policy_set_id): """ Delete a specific policy set by id. Method is idempotent. """ uri = self._get_policy_set_uri(guid=policy_set_id) return self.service._delete(uri)
[ "def", "delete_policy_set", "(", "self", ",", "policy_set_id", ")", ":", "uri", "=", "self", ".", "_get_policy_set_uri", "(", "guid", "=", "policy_set_id", ")", "return", "self", ".", "service", ".", "_delete", "(", "uri", ")" ]
Delete a specific policy set by id. Method is idempotent.
[ "Delete", "a", "specific", "policy", "set", "by", "id", ".", "Method", "is", "idempotent", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L320-L325
train
PredixDev/predixpy
predix/security/acs.py
AccessControl.add_policy
def add_policy(self, name, action, resource, subject, condition, policy_set_id=None, effect='PERMIT'): """ Will create a new policy set to enforce the given policy details. The name is just a helpful descriptor for the policy. The action maps to a HTTP verb. Polici...
python
def add_policy(self, name, action, resource, subject, condition, policy_set_id=None, effect='PERMIT'): """ Will create a new policy set to enforce the given policy details. The name is just a helpful descriptor for the policy. The action maps to a HTTP verb. Polici...
[ "def", "add_policy", "(", "self", ",", "name", ",", "action", ",", "resource", ",", "subject", ",", "condition", ",", "policy_set_id", "=", "None", ",", "effect", "=", "'PERMIT'", ")", ":", "# If not given a policy set id will generate one", "if", "not", "policy...
Will create a new policy set to enforce the given policy details. The name is just a helpful descriptor for the policy. The action maps to a HTTP verb. Policies are evaluated against resources and subjects. They are identified by matching a uriTemplate or attributes. Example...
[ "Will", "create", "a", "new", "policy", "set", "to", "enforce", "the", "given", "policy", "details", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L327-L391
train
PredixDev/predixpy
predix/security/acs.py
AccessControl.is_allowed
def is_allowed(self, subject_id, action, resource_id, policy_sets=[]): """ Evaluate a policy-set against a subject and resource. example/ is_allowed('/user/j12y', 'GET', '/asset/12') """ body = { "action": action, "subjectIdentifier": subjec...
python
def is_allowed(self, subject_id, action, resource_id, policy_sets=[]): """ Evaluate a policy-set against a subject and resource. example/ is_allowed('/user/j12y', 'GET', '/asset/12') """ body = { "action": action, "subjectIdentifier": subjec...
[ "def", "is_allowed", "(", "self", ",", "subject_id", ",", "action", ",", "resource_id", ",", "policy_sets", "=", "[", "]", ")", ":", "body", "=", "{", "\"action\"", ":", "action", ",", "\"subjectIdentifier\"", ":", "subject_id", ",", "\"resourceIdentifier\"", ...
Evaluate a policy-set against a subject and resource. example/ is_allowed('/user/j12y', 'GET', '/asset/12')
[ "Evaluate", "a", "policy", "-", "set", "against", "a", "subject", "and", "resource", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L393-L423
train
shichao-an/homura
homura.py
download
def download(url, path=None, headers=None, session=None, show_progress=True, resume=True, auto_retry=True, max_rst_retries=5, pass_through_opts=None, cainfo=None, user_agent=None, auth=None): """Main download function""" hm = Homura(url, path, headers, session, show_progress, resume, ...
python
def download(url, path=None, headers=None, session=None, show_progress=True, resume=True, auto_retry=True, max_rst_retries=5, pass_through_opts=None, cainfo=None, user_agent=None, auth=None): """Main download function""" hm = Homura(url, path, headers, session, show_progress, resume, ...
[ "def", "download", "(", "url", ",", "path", "=", "None", ",", "headers", "=", "None", ",", "session", "=", "None", ",", "show_progress", "=", "True", ",", "resume", "=", "True", ",", "auto_retry", "=", "True", ",", "max_rst_retries", "=", "5", ",", "...
Main download function
[ "Main", "download", "function" ]
87d1b698e1196963a23fc1c615c12020daf77dcc
https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L304-L311
train
shichao-an/homura
homura.py
Homura._fill_in_cainfo
def _fill_in_cainfo(self): """Fill in the path of the PEM file containing the CA certificate. The priority is: 1. user provided path, 2. path to the cacert.pem bundle provided by certifi (if installed), 3. let pycurl use the system path where libcurl's cacert bundle is assumed to be sto...
python
def _fill_in_cainfo(self): """Fill in the path of the PEM file containing the CA certificate. The priority is: 1. user provided path, 2. path to the cacert.pem bundle provided by certifi (if installed), 3. let pycurl use the system path where libcurl's cacert bundle is assumed to be sto...
[ "def", "_fill_in_cainfo", "(", "self", ")", ":", "if", "self", ".", "cainfo", ":", "cainfo", "=", "self", ".", "cainfo", "else", ":", "try", ":", "cainfo", "=", "certifi", ".", "where", "(", ")", "except", "AttributeError", ":", "cainfo", "=", "None", ...
Fill in the path of the PEM file containing the CA certificate. The priority is: 1. user provided path, 2. path to the cacert.pem bundle provided by certifi (if installed), 3. let pycurl use the system path where libcurl's cacert bundle is assumed to be stored, as established at libcurl...
[ "Fill", "in", "the", "path", "of", "the", "PEM", "file", "containing", "the", "CA", "certificate", "." ]
87d1b698e1196963a23fc1c615c12020daf77dcc
https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L159-L175
train
shichao-an/homura
homura.py
Homura.curl
def curl(self): """Sending a single cURL request to download""" c = self._pycurl # Resume download if os.path.exists(self.path) and self.resume: mode = 'ab' self.downloaded = os.path.getsize(self.path) c.setopt(pycurl.RESUME_FROM, self.downloaded) ...
python
def curl(self): """Sending a single cURL request to download""" c = self._pycurl # Resume download if os.path.exists(self.path) and self.resume: mode = 'ab' self.downloaded = os.path.getsize(self.path) c.setopt(pycurl.RESUME_FROM, self.downloaded) ...
[ "def", "curl", "(", "self", ")", ":", "c", "=", "self", ".", "_pycurl", "# Resume download", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "path", ")", "and", "self", ".", "resume", ":", "mode", "=", "'ab'", "self", ".", "downloaded", "...
Sending a single cURL request to download
[ "Sending", "a", "single", "cURL", "request", "to", "download" ]
87d1b698e1196963a23fc1c615c12020daf77dcc
https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L177-L203
train
shichao-an/homura
homura.py
Homura.start
def start(self): """ Start downloading, handling auto retry, download resume and path moving """ if not self.auto_retry: self.curl() return while not self.is_finished: try: self.curl() except pycurl.error as ...
python
def start(self): """ Start downloading, handling auto retry, download resume and path moving """ if not self.auto_retry: self.curl() return while not self.is_finished: try: self.curl() except pycurl.error as ...
[ "def", "start", "(", "self", ")", ":", "if", "not", "self", ".", "auto_retry", ":", "self", ".", "curl", "(", ")", "return", "while", "not", "self", ".", "is_finished", ":", "try", ":", "self", ".", "curl", "(", ")", "except", "pycurl", ".", "error...
Start downloading, handling auto retry, download resume and path moving
[ "Start", "downloading", "handling", "auto", "retry", "download", "resume", "and", "path", "moving" ]
87d1b698e1196963a23fc1c615c12020daf77dcc
https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L205-L234
train
shichao-an/homura
homura.py
Homura._move_path
def _move_path(self): """ Move the downloaded file to the authentic path (identified by effective URL) """ if is_temp_path(self._path) and self._pycurl is not None: eurl = self._pycurl.getinfo(pycurl.EFFECTIVE_URL) er = get_resource_name(eurl) ...
python
def _move_path(self): """ Move the downloaded file to the authentic path (identified by effective URL) """ if is_temp_path(self._path) and self._pycurl is not None: eurl = self._pycurl.getinfo(pycurl.EFFECTIVE_URL) er = get_resource_name(eurl) ...
[ "def", "_move_path", "(", "self", ")", ":", "if", "is_temp_path", "(", "self", ".", "_path", ")", "and", "self", ".", "_pycurl", "is", "not", "None", ":", "eurl", "=", "self", ".", "_pycurl", ".", "getinfo", "(", "pycurl", ".", "EFFECTIVE_URL", ")", ...
Move the downloaded file to the authentic path (identified by effective URL)
[ "Move", "the", "downloaded", "file", "to", "the", "authentic", "path", "(", "identified", "by", "effective", "URL", ")" ]
87d1b698e1196963a23fc1c615c12020daf77dcc
https://github.com/shichao-an/homura/blob/87d1b698e1196963a23fc1c615c12020daf77dcc/homura.py#L289-L301
train
PredixDev/predixpy
predix/admin/uaa.py
UserAccountAuthentication.create
def create(self, secret, **kwargs): """ Create a new instance of the UAA service. Requires a secret password for the 'admin' user account. """ parameters = {"adminClientSecret": secret} self.service.create(parameters=parameters) # Store URI into environment vari...
python
def create(self, secret, **kwargs): """ Create a new instance of the UAA service. Requires a secret password for the 'admin' user account. """ parameters = {"adminClientSecret": secret} self.service.create(parameters=parameters) # Store URI into environment vari...
[ "def", "create", "(", "self", ",", "secret", ",", "*", "*", "kwargs", ")", ":", "parameters", "=", "{", "\"adminClientSecret\"", ":", "secret", "}", "self", ".", "service", ".", "create", "(", "parameters", "=", "parameters", ")", "# Store URI into environme...
Create a new instance of the UAA service. Requires a secret password for the 'admin' user account.
[ "Create", "a", "new", "instance", "of", "the", "UAA", "service", ".", "Requires", "a", "secret", "password", "for", "the", "admin", "user", "account", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L53-L65
train
PredixDev/predixpy
predix/admin/uaa.py
UserAccountAuthentication.add_to_manifest
def add_to_manifest(self, manifest): """ Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry...
python
def add_to_manifest(self, manifest): """ Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry...
[ "def", "add_to_manifest", "(", "self", ",", "manifest", ")", ":", "# Add this service to list of services", "manifest", ".", "add_service", "(", "self", ".", "service", ".", "name", ")", "# Add environment variable to manifest", "varname", "=", "predix", ".", "config"...
Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry app.
[ "Add", "useful", "details", "to", "the", "manifest", "about", "this", "service", "so", "that", "it", "can", "be", "used", "in", "an", "application", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L67-L84
train
PredixDev/predixpy
predix/admin/uaa.py
UserAccountAuthentication.authenticate
def authenticate(self): """ Authenticate into the UAA instance as the admin user. """ # Make sure we've stored uri for use predix.config.set_env_value(self.use_class, 'uri', self._get_uri()) self.uaac = predix.security.uaa.UserAccountAuthentication() self.uaac.au...
python
def authenticate(self): """ Authenticate into the UAA instance as the admin user. """ # Make sure we've stored uri for use predix.config.set_env_value(self.use_class, 'uri', self._get_uri()) self.uaac = predix.security.uaa.UserAccountAuthentication() self.uaac.au...
[ "def", "authenticate", "(", "self", ")", ":", "# Make sure we've stored uri for use", "predix", ".", "config", ".", "set_env_value", "(", "self", ".", "use_class", ",", "'uri'", ",", "self", ".", "_get_uri", "(", ")", ")", "self", ".", "uaac", "=", "predix",...
Authenticate into the UAA instance as the admin user.
[ "Authenticate", "into", "the", "UAA", "instance", "as", "the", "admin", "user", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L86-L96
train
PredixDev/predixpy
predix/admin/uaa.py
UserAccountAuthentication._create_secret
def _create_secret(self, length=12): """ Use a cryptograhically-secure Pseudorandom number generator for picking a combination of letters, digits, and punctuation to be our secret. :param length: how long to make the secret (12 seems ok most of the time) """ # Charset w...
python
def _create_secret(self, length=12): """ Use a cryptograhically-secure Pseudorandom number generator for picking a combination of letters, digits, and punctuation to be our secret. :param length: how long to make the secret (12 seems ok most of the time) """ # Charset w...
[ "def", "_create_secret", "(", "self", ",", "length", "=", "12", ")", ":", "# Charset will have 64 +- characters", "charset", "=", "string", ".", "digits", "+", "string", ".", "ascii_letters", "+", "'+-'", "return", "\"\"", ".", "join", "(", "random", ".", "S...
Use a cryptograhically-secure Pseudorandom number generator for picking a combination of letters, digits, and punctuation to be our secret. :param length: how long to make the secret (12 seems ok most of the time)
[ "Use", "a", "cryptograhically", "-", "secure", "Pseudorandom", "number", "generator", "for", "picking", "a", "combination", "of", "letters", "digits", "and", "punctuation", "to", "be", "our", "secret", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L104-L115
train
PredixDev/predixpy
predix/admin/uaa.py
UserAccountAuthentication.create_client
def create_client(self, client_id, client_secret): """ Create a new client for use by applications. """ assert self.is_admin, "Must authenticate() as admin to create client" return self.uaac.create_client(client_id, client_secret)
python
def create_client(self, client_id, client_secret): """ Create a new client for use by applications. """ assert self.is_admin, "Must authenticate() as admin to create client" return self.uaac.create_client(client_id, client_secret)
[ "def", "create_client", "(", "self", ",", "client_id", ",", "client_secret", ")", ":", "assert", "self", ".", "is_admin", ",", "\"Must authenticate() as admin to create client\"", "return", "self", ".", "uaac", ".", "create_client", "(", "client_id", ",", "client_se...
Create a new client for use by applications.
[ "Create", "a", "new", "client", "for", "use", "by", "applications", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L117-L122
train
PredixDev/predixpy
predix/admin/uaa.py
UserAccountAuthentication.add_client_to_manifest
def add_client_to_manifest(self, client_id, client_secret, manifest): """ Add the client credentials to the specified manifest. """ assert self.is_admin, "Must authenticate() as admin to create client" return self.uaac.add_client_to_manifest(client_id, client_secret, ...
python
def add_client_to_manifest(self, client_id, client_secret, manifest): """ Add the client credentials to the specified manifest. """ assert self.is_admin, "Must authenticate() as admin to create client" return self.uaac.add_client_to_manifest(client_id, client_secret, ...
[ "def", "add_client_to_manifest", "(", "self", ",", "client_id", ",", "client_secret", ",", "manifest", ")", ":", "assert", "self", ".", "is_admin", ",", "\"Must authenticate() as admin to create client\"", "return", "self", ".", "uaac", ".", "add_client_to_manifest", ...
Add the client credentials to the specified manifest.
[ "Add", "the", "client", "credentials", "to", "the", "specified", "manifest", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L124-L130
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication._get_uaa_uri
def _get_uaa_uri(self): """ Returns the URI endpoint for an instance of a UAA service instance from environment inspection. """ if 'VCAP_SERVICES' in os.environ: services = json.loads(os.getenv('VCAP_SERVICES')) predix_uaa = services['predix-uaa'][0]['cred...
python
def _get_uaa_uri(self): """ Returns the URI endpoint for an instance of a UAA service instance from environment inspection. """ if 'VCAP_SERVICES' in os.environ: services = json.loads(os.getenv('VCAP_SERVICES')) predix_uaa = services['predix-uaa'][0]['cred...
[ "def", "_get_uaa_uri", "(", "self", ")", ":", "if", "'VCAP_SERVICES'", "in", "os", ".", "environ", ":", "services", "=", "json", ".", "loads", "(", "os", ".", "getenv", "(", "'VCAP_SERVICES'", ")", ")", "predix_uaa", "=", "services", "[", "'predix-uaa'", ...
Returns the URI endpoint for an instance of a UAA service instance from environment inspection.
[ "Returns", "the", "URI", "endpoint", "for", "an", "instance", "of", "a", "UAA", "service", "instance", "from", "environment", "inspection", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L35-L45
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication._authenticate_client
def _authenticate_client(self, client, secret): """ Returns response of authenticating with the given client and secret. """ client_s = str.join(':', [client, secret]) credentials = base64.b64encode(client_s.encode('utf-8')).decode('utf-8') headers = { ...
python
def _authenticate_client(self, client, secret): """ Returns response of authenticating with the given client and secret. """ client_s = str.join(':', [client, secret]) credentials = base64.b64encode(client_s.encode('utf-8')).decode('utf-8') headers = { ...
[ "def", "_authenticate_client", "(", "self", ",", "client", ",", "secret", ")", ":", "client_s", "=", "str", ".", "join", "(", "':'", ",", "[", "client", ",", "secret", "]", ")", "credentials", "=", "base64", ".", "b64encode", "(", "client_s", ".", "enc...
Returns response of authenticating with the given client and secret.
[ "Returns", "response", "of", "authenticating", "with", "the", "given", "client", "and", "secret", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L47-L76
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication._authenticate_user
def _authenticate_user(self, user, password): """ Returns the response of authenticating with the given user and password. """ headers = self._get_headers() params = { 'username': user, 'password': password, 'grant_type': 'p...
python
def _authenticate_user(self, user, password): """ Returns the response of authenticating with the given user and password. """ headers = self._get_headers() params = { 'username': user, 'password': password, 'grant_type': 'p...
[ "def", "_authenticate_user", "(", "self", ",", "user", ",", "password", ")", ":", "headers", "=", "self", ".", "_get_headers", "(", ")", "params", "=", "{", "'username'", ":", "user", ",", "'password'", ":", "password", ",", "'grant_type'", ":", "'password...
Returns the response of authenticating with the given user and password.
[ "Returns", "the", "response", "of", "authenticating", "with", "the", "given", "user", "and", "password", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L78-L101
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.is_expired_token
def is_expired_token(self, client): """ For a given client will test whether or not the token has expired. This is for testing a client object and does not look up from client_id. You can use _get_client_from_cache() to lookup a client from client_id. """ ...
python
def is_expired_token(self, client): """ For a given client will test whether or not the token has expired. This is for testing a client object and does not look up from client_id. You can use _get_client_from_cache() to lookup a client from client_id. """ ...
[ "def", "is_expired_token", "(", "self", ",", "client", ")", ":", "if", "'expires'", "not", "in", "client", ":", "return", "True", "expires", "=", "dateutil", ".", "parser", ".", "parse", "(", "client", "[", "'expires'", "]", ")", "if", "expires", "<", ...
For a given client will test whether or not the token has expired. This is for testing a client object and does not look up from client_id. You can use _get_client_from_cache() to lookup a client from client_id.
[ "For", "a", "given", "client", "will", "test", "whether", "or", "not", "the", "token", "has", "expired", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L103-L119
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication._initialize_uaa_cache
def _initialize_uaa_cache(self): """ If we don't yet have a uaa cache we need to initialize it. As there may be more than one UAA instance we index by issuer and then store any clients, users, etc. """ try: os.makedirs(os.path.dirname(self._cache_path...
python
def _initialize_uaa_cache(self): """ If we don't yet have a uaa cache we need to initialize it. As there may be more than one UAA instance we index by issuer and then store any clients, users, etc. """ try: os.makedirs(os.path.dirname(self._cache_path...
[ "def", "_initialize_uaa_cache", "(", "self", ")", ":", "try", ":", "os", ".", "makedirs", "(", "os", ".", "path", ".", "dirname", "(", "self", ".", "_cache_path", ")", ")", "except", "OSError", "as", "exc", ":", "if", "exc", ".", "errno", "!=", "errn...
If we don't yet have a uaa cache we need to initialize it. As there may be more than one UAA instance we index by issuer and then store any clients, users, etc.
[ "If", "we", "don", "t", "yet", "have", "a", "uaa", "cache", "we", "need", "to", "initialize", "it", ".", "As", "there", "may", "be", "more", "than", "one", "UAA", "instance", "we", "index", "by", "issuer", "and", "then", "store", "any", "clients", "u...
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L121-L137
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication._read_uaa_cache
def _read_uaa_cache(self): """ Read cache of UAA client/user details. """ self._cache_path = os.path.expanduser('~/.predix/uaa.json') if not os.path.exists(self._cache_path): return self._initialize_uaa_cache() with open(self._cache_path, 'r') as data: ...
python
def _read_uaa_cache(self): """ Read cache of UAA client/user details. """ self._cache_path = os.path.expanduser('~/.predix/uaa.json') if not os.path.exists(self._cache_path): return self._initialize_uaa_cache() with open(self._cache_path, 'r') as data: ...
[ "def", "_read_uaa_cache", "(", "self", ")", ":", "self", ".", "_cache_path", "=", "os", ".", "path", ".", "expanduser", "(", "'~/.predix/uaa.json'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "_cache_path", ")", ":", "return", ...
Read cache of UAA client/user details.
[ "Read", "cache", "of", "UAA", "client", "/", "user", "details", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L139-L148
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication._get_client_from_cache
def _get_client_from_cache(self, client_id): """ For the given client_id return what is cached. """ data = self._read_uaa_cache() # Only if we've cached any for this issuer if self.uri not in data: return for client in data[self.uri]: ...
python
def _get_client_from_cache(self, client_id): """ For the given client_id return what is cached. """ data = self._read_uaa_cache() # Only if we've cached any for this issuer if self.uri not in data: return for client in data[self.uri]: ...
[ "def", "_get_client_from_cache", "(", "self", ",", "client_id", ")", ":", "data", "=", "self", ".", "_read_uaa_cache", "(", ")", "# Only if we've cached any for this issuer", "if", "self", ".", "uri", "not", "in", "data", ":", "return", "for", "client", "in", ...
For the given client_id return what is cached.
[ "For", "the", "given", "client_id", "return", "what", "is", "cached", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L150-L163
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication._write_to_uaa_cache
def _write_to_uaa_cache(self, new_item): """ Cache the client details into a cached file on disk. """ data = self._read_uaa_cache() # Initialize client list if first time if self.uri not in data: data[self.uri] = [] # Remove existing client record an...
python
def _write_to_uaa_cache(self, new_item): """ Cache the client details into a cached file on disk. """ data = self._read_uaa_cache() # Initialize client list if first time if self.uri not in data: data[self.uri] = [] # Remove existing client record an...
[ "def", "_write_to_uaa_cache", "(", "self", ",", "new_item", ")", ":", "data", "=", "self", ".", "_read_uaa_cache", "(", ")", "# Initialize client list if first time", "if", "self", ".", "uri", "not", "in", "data", ":", "data", "[", "self", ".", "uri", "]", ...
Cache the client details into a cached file on disk.
[ "Cache", "the", "client", "details", "into", "a", "cached", "file", "on", "disk", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L165-L191
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.authenticate
def authenticate(self, client_id, client_secret, use_cache=True): """ Authenticate the given client against UAA. The resulting token will be cached for reuse. """ # We will reuse a token for as long as we have one cached # and it hasn't expired. if use_cache: ...
python
def authenticate(self, client_id, client_secret, use_cache=True): """ Authenticate the given client against UAA. The resulting token will be cached for reuse. """ # We will reuse a token for as long as we have one cached # and it hasn't expired. if use_cache: ...
[ "def", "authenticate", "(", "self", ",", "client_id", ",", "client_secret", ",", "use_cache", "=", "True", ")", ":", "# We will reuse a token for as long as we have one cached", "# and it hasn't expired.", "if", "use_cache", ":", "client", "=", "self", ".", "_get_client...
Authenticate the given client against UAA. The resulting token will be cached for reuse.
[ "Authenticate", "the", "given", "client", "against", "UAA", ".", "The", "resulting", "token", "will", "be", "cached", "for", "reuse", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L193-L224
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.logout
def logout(self): """ Log currently authenticated user out, invalidating any existing tokens. """ # Remove token from local cache # MAINT: need to expire token on server data = self._read_uaa_cache() if self.uri in data: for client in data[self.uri]: ...
python
def logout(self): """ Log currently authenticated user out, invalidating any existing tokens. """ # Remove token from local cache # MAINT: need to expire token on server data = self._read_uaa_cache() if self.uri in data: for client in data[self.uri]: ...
[ "def", "logout", "(", "self", ")", ":", "# Remove token from local cache", "# MAINT: need to expire token on server", "data", "=", "self", ".", "_read_uaa_cache", "(", ")", "if", "self", ".", "uri", "in", "data", ":", "for", "client", "in", "data", "[", "self", ...
Log currently authenticated user out, invalidating any existing tokens.
[ "Log", "currently", "authenticated", "user", "out", "invalidating", "any", "existing", "tokens", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L226-L239
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication._post
def _post(self, uri, data, headers=None): """ Simple POST request for a given uri path. """ if not headers: headers = self._get_headers() logging.debug("URI=" + str(uri)) logging.debug("HEADERS=" + str(headers)) logging.debug("BODY=" + str(data)) ...
python
def _post(self, uri, data, headers=None): """ Simple POST request for a given uri path. """ if not headers: headers = self._get_headers() logging.debug("URI=" + str(uri)) logging.debug("HEADERS=" + str(headers)) logging.debug("BODY=" + str(data)) ...
[ "def", "_post", "(", "self", ",", "uri", ",", "data", ",", "headers", "=", "None", ")", ":", "if", "not", "headers", ":", "headers", "=", "self", ".", "_get_headers", "(", ")", "logging", ".", "debug", "(", "\"URI=\"", "+", "str", "(", "uri", ")", ...
Simple POST request for a given uri path.
[ "Simple", "POST", "request", "for", "a", "given", "uri", "path", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L272-L291
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.get_token
def get_token(self): """ Returns the bare access token for the authorized client. """ if not self.authenticated: raise ValueError("Must authenticate() as a client first.") # If token has expired we'll need to refresh and get a new # client credential ...
python
def get_token(self): """ Returns the bare access token for the authorized client. """ if not self.authenticated: raise ValueError("Must authenticate() as a client first.") # If token has expired we'll need to refresh and get a new # client credential ...
[ "def", "get_token", "(", "self", ")", ":", "if", "not", "self", ".", "authenticated", ":", "raise", "ValueError", "(", "\"Must authenticate() as a client first.\"", ")", "# If token has expired we'll need to refresh and get a new", "# client credential", "if", "self", ".", ...
Returns the bare access token for the authorized client.
[ "Returns", "the", "bare", "access", "token", "for", "the", "authorized", "client", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L293-L307
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.get_scopes
def get_scopes(self): """ Returns the scopes for the authenticated client. """ if not self.authenticated: raise ValueError("Must authenticate() as a client first.") scope = self.client['scope'] return scope.split()
python
def get_scopes(self): """ Returns the scopes for the authenticated client. """ if not self.authenticated: raise ValueError("Must authenticate() as a client first.") scope = self.client['scope'] return scope.split()
[ "def", "get_scopes", "(", "self", ")", ":", "if", "not", "self", ".", "authenticated", ":", "raise", "ValueError", "(", "\"Must authenticate() as a client first.\"", ")", "scope", "=", "self", ".", "client", "[", "'scope'", "]", "return", "scope", ".", "split"...
Returns the scopes for the authenticated client.
[ "Returns", "the", "scopes", "for", "the", "authenticated", "client", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L309-L317
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.assert_has_permission
def assert_has_permission(self, scope_required): """ Warn that the required scope is not found in the scopes granted to the currently authenticated user. :: # The admin user should have client admin permissions uaa.assert_has_permission('admin', 'clients.admin')...
python
def assert_has_permission(self, scope_required): """ Warn that the required scope is not found in the scopes granted to the currently authenticated user. :: # The admin user should have client admin permissions uaa.assert_has_permission('admin', 'clients.admin')...
[ "def", "assert_has_permission", "(", "self", ",", "scope_required", ")", ":", "if", "not", "self", ".", "authenticated", ":", "raise", "ValueError", "(", "\"Must first authenticate()\"", ")", "if", "scope_required", "not", "in", "self", ".", "get_scopes", "(", "...
Warn that the required scope is not found in the scopes granted to the currently authenticated user. :: # The admin user should have client admin permissions uaa.assert_has_permission('admin', 'clients.admin')
[ "Warn", "that", "the", "required", "scope", "is", "not", "found", "in", "the", "scopes", "granted", "to", "the", "currently", "authenticated", "user", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L334-L355
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.grant_client_permissions
def grant_client_permissions(self, client_id, admin=False, write=False, read=False, secret=False): """ Grant the given client_id permissions for managing clients. - clients.admin: super user scope to create, modify, delete - clients.write: scope ot create and modify clients ...
python
def grant_client_permissions(self, client_id, admin=False, write=False, read=False, secret=False): """ Grant the given client_id permissions for managing clients. - clients.admin: super user scope to create, modify, delete - clients.write: scope ot create and modify clients ...
[ "def", "grant_client_permissions", "(", "self", ",", "client_id", ",", "admin", "=", "False", ",", "write", "=", "False", ",", "read", "=", "False", ",", "secret", "=", "False", ")", ":", "self", ".", "assert_has_permission", "(", "'clients.admin'", ")", "...
Grant the given client_id permissions for managing clients. - clients.admin: super user scope to create, modify, delete - clients.write: scope ot create and modify clients - clients.read: scope to read info about clients - clients.secret: scope to change password of a client
[ "Grant", "the", "given", "client_id", "permissions", "for", "managing", "clients", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L357-L385
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.get_clients
def get_clients(self): """ Returns the clients stored in the instance of UAA. """ self.assert_has_permission('clients.read') uri = self.uri + '/oauth/clients' headers = self.get_authorization_headers() response = requests.get(uri, headers=headers) return ...
python
def get_clients(self): """ Returns the clients stored in the instance of UAA. """ self.assert_has_permission('clients.read') uri = self.uri + '/oauth/clients' headers = self.get_authorization_headers() response = requests.get(uri, headers=headers) return ...
[ "def", "get_clients", "(", "self", ")", ":", "self", ".", "assert_has_permission", "(", "'clients.read'", ")", "uri", "=", "self", ".", "uri", "+", "'/oauth/clients'", "headers", "=", "self", ".", "get_authorization_headers", "(", ")", "response", "=", "reques...
Returns the clients stored in the instance of UAA.
[ "Returns", "the", "clients", "stored", "in", "the", "instance", "of", "UAA", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L387-L396
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.get_client
def get_client(self, client_id): """ Returns details about a specific client by the client_id. """ self.assert_has_permission('clients.read') uri = self.uri + '/oauth/clients/' + client_id headers = self.get_authorization_headers() response = requests.get(uri, he...
python
def get_client(self, client_id): """ Returns details about a specific client by the client_id. """ self.assert_has_permission('clients.read') uri = self.uri + '/oauth/clients/' + client_id headers = self.get_authorization_headers() response = requests.get(uri, he...
[ "def", "get_client", "(", "self", ",", "client_id", ")", ":", "self", ".", "assert_has_permission", "(", "'clients.read'", ")", "uri", "=", "self", ".", "uri", "+", "'/oauth/clients/'", "+", "client_id", "headers", "=", "self", ".", "get_authorization_headers", ...
Returns details about a specific client by the client_id.
[ "Returns", "details", "about", "a", "specific", "client", "by", "the", "client_id", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L398-L411
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.update_client_grants
def update_client_grants(self, client_id, scope=[], authorities=[], grant_types=[], redirect_uri=[], replace=False): """ Will extend the client with additional scopes or authorities. Any existing scopes and authorities will be left as is unless asked to replace entirely. ...
python
def update_client_grants(self, client_id, scope=[], authorities=[], grant_types=[], redirect_uri=[], replace=False): """ Will extend the client with additional scopes or authorities. Any existing scopes and authorities will be left as is unless asked to replace entirely. ...
[ "def", "update_client_grants", "(", "self", ",", "client_id", ",", "scope", "=", "[", "]", ",", "authorities", "=", "[", "]", ",", "grant_types", "=", "[", "]", ",", "redirect_uri", "=", "[", "]", ",", "replace", "=", "False", ")", ":", "self", ".", ...
Will extend the client with additional scopes or authorities. Any existing scopes and authorities will be left as is unless asked to replace entirely.
[ "Will", "extend", "the", "client", "with", "additional", "scopes", "or", "authorities", ".", "Any", "existing", "scopes", "and", "authorities", "will", "be", "left", "as", "is", "unless", "asked", "to", "replace", "entirely", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L413-L476
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.grant_scim_permissions
def grant_scim_permissions(self, client_id, read=False, write=False, create=False, userids=False, zones=False, invite=False, openid=False): """ Grant the given client_id permissions for managing users. System for Cross-domain Identity Management (SCIM) are required for a...
python
def grant_scim_permissions(self, client_id, read=False, write=False, create=False, userids=False, zones=False, invite=False, openid=False): """ Grant the given client_id permissions for managing users. System for Cross-domain Identity Management (SCIM) are required for a...
[ "def", "grant_scim_permissions", "(", "self", ",", "client_id", ",", "read", "=", "False", ",", "write", "=", "False", ",", "create", "=", "False", ",", "userids", "=", "False", ",", "zones", "=", "False", ",", "invite", "=", "False", ",", "openid", "=...
Grant the given client_id permissions for managing users. System for Cross-domain Identity Management (SCIM) are required for accessing /Users and /Groups endpoints of UAA. - scim.read: scope for read access to all SCIM endpoints - scim.write: scope for write access to all SCIM endpoin...
[ "Grant", "the", "given", "client_id", "permissions", "for", "managing", "users", ".", "System", "for", "Cross", "-", "domain", "Identity", "Management", "(", "SCIM", ")", "are", "required", "for", "accessing", "/", "Users", "and", "/", "Groups", "endpoints", ...
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L478-L520
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.create_client
def create_client(self, client_id, client_secret, manifest=None, client_credentials=True, refresh_token=True, authorization_code=False, redirect_uri=[]): """ Will create a new client for your application use. - client_credentials: allows client to get access token ...
python
def create_client(self, client_id, client_secret, manifest=None, client_credentials=True, refresh_token=True, authorization_code=False, redirect_uri=[]): """ Will create a new client for your application use. - client_credentials: allows client to get access token ...
[ "def", "create_client", "(", "self", ",", "client_id", ",", "client_secret", ",", "manifest", "=", "None", ",", "client_credentials", "=", "True", ",", "refresh_token", "=", "True", ",", "authorization_code", "=", "False", ",", "redirect_uri", "=", "[", "]", ...
Will create a new client for your application use. - client_credentials: allows client to get access token - refresh_token: can be used to get new access token when expired without re-authenticating - authorization_code: redirection-based flow for user authentication More det...
[ "Will", "create", "a", "new", "client", "for", "your", "application", "use", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L522-L594
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.add_client_to_manifest
def add_client_to_manifest(self, client_id, client_secret, manifest): """ Add the given client / secret to the manifest for use in the application. """ client_id_key = 'PREDIX_APP_CLIENT_ID' manifest.add_env_var(client_id_key, client_id) client_secret_key = 'PRED...
python
def add_client_to_manifest(self, client_id, client_secret, manifest): """ Add the given client / secret to the manifest for use in the application. """ client_id_key = 'PREDIX_APP_CLIENT_ID' manifest.add_env_var(client_id_key, client_id) client_secret_key = 'PRED...
[ "def", "add_client_to_manifest", "(", "self", ",", "client_id", ",", "client_secret", ",", "manifest", ")", ":", "client_id_key", "=", "'PREDIX_APP_CLIENT_ID'", "manifest", ".", "add_env_var", "(", "client_id_key", ",", "client_id", ")", "client_secret_key", "=", "'...
Add the given client / secret to the manifest for use in the application.
[ "Add", "the", "given", "client", "/", "secret", "to", "the", "manifest", "for", "use", "in", "the", "application", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L596-L607
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.create_user
def create_user(self, username, password, family_name, given_name, primary_email, details={}): """ Creates a new user account with the required details. :: create_user('j12y', 'my-secret', 'Delancey', 'Jayson', 'volcano@ge.com') """ self.assert_has_perm...
python
def create_user(self, username, password, family_name, given_name, primary_email, details={}): """ Creates a new user account with the required details. :: create_user('j12y', 'my-secret', 'Delancey', 'Jayson', 'volcano@ge.com') """ self.assert_has_perm...
[ "def", "create_user", "(", "self", ",", "username", ",", "password", ",", "family_name", ",", "given_name", ",", "primary_email", ",", "details", "=", "{", "}", ")", ":", "self", ".", "assert_has_permission", "(", "'scim.write'", ")", "data", "=", "{", "'u...
Creates a new user account with the required details. :: create_user('j12y', 'my-secret', 'Delancey', 'Jayson', 'volcano@ge.com')
[ "Creates", "a", "new", "user", "account", "with", "the", "required", "details", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L619-L647
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.delete_user
def delete_user(self, id): """ Delete user with given id. """ self.assert_has_permission('scim.write') uri = self.uri + '/Users/%s' % id headers = self._get_headers() logging.debug("URI=" + str(uri)) logging.debug("HEADERS=" + str(headers)) resp...
python
def delete_user(self, id): """ Delete user with given id. """ self.assert_has_permission('scim.write') uri = self.uri + '/Users/%s' % id headers = self._get_headers() logging.debug("URI=" + str(uri)) logging.debug("HEADERS=" + str(headers)) resp...
[ "def", "delete_user", "(", "self", ",", "id", ")", ":", "self", ".", "assert_has_permission", "(", "'scim.write'", ")", "uri", "=", "self", ".", "uri", "+", "'/Users/%s'", "%", "id", "headers", "=", "self", ".", "_get_headers", "(", ")", "logging", ".", ...
Delete user with given id.
[ "Delete", "user", "with", "given", "id", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L649-L667
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.get_users
def get_users(self, filter=None, sortBy=None, sortOrder=None, startIndex=None, count=None): """ Returns users accounts stored in UAA. See https://docs.cloudfoundry.org/api/uaa/#list63 For filtering help, see: http://www.simplecloud.info/specs/draft-scim-api-01.html#q...
python
def get_users(self, filter=None, sortBy=None, sortOrder=None, startIndex=None, count=None): """ Returns users accounts stored in UAA. See https://docs.cloudfoundry.org/api/uaa/#list63 For filtering help, see: http://www.simplecloud.info/specs/draft-scim-api-01.html#q...
[ "def", "get_users", "(", "self", ",", "filter", "=", "None", ",", "sortBy", "=", "None", ",", "sortOrder", "=", "None", ",", "startIndex", "=", "None", ",", "count", "=", "None", ")", ":", "self", ".", "assert_has_permission", "(", "'scim.read'", ")", ...
Returns users accounts stored in UAA. See https://docs.cloudfoundry.org/api/uaa/#list63 For filtering help, see: http://www.simplecloud.info/specs/draft-scim-api-01.html#query-resources
[ "Returns", "users", "accounts", "stored", "in", "UAA", ".", "See", "https", ":", "//", "docs", ".", "cloudfoundry", ".", "org", "/", "api", "/", "uaa", "/", "#list63" ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L669-L696
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.get_user_by_username
def get_user_by_username(self, username): """ Returns details for user of the given username. If there is more than one match will only return the first. Use get_users() for full result set. """ results = self.get_users(filter='username eq "%s"' % (username)) if...
python
def get_user_by_username(self, username): """ Returns details for user of the given username. If there is more than one match will only return the first. Use get_users() for full result set. """ results = self.get_users(filter='username eq "%s"' % (username)) if...
[ "def", "get_user_by_username", "(", "self", ",", "username", ")", ":", "results", "=", "self", ".", "get_users", "(", "filter", "=", "'username eq \"%s\"'", "%", "(", "username", ")", ")", "if", "results", "[", "'totalResults'", "]", "==", "0", ":", "loggi...
Returns details for user of the given username. If there is more than one match will only return the first. Use get_users() for full result set.
[ "Returns", "details", "for", "user", "of", "the", "given", "username", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L698-L713
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.get_user_by_email
def get_user_by_email(self, email): """ Returns details for user with the given email address. If there is more than one match will only return the first. Use get_users() for full result set. """ results = self.get_users(filter='email eq "%s"' % (email)) if resu...
python
def get_user_by_email(self, email): """ Returns details for user with the given email address. If there is more than one match will only return the first. Use get_users() for full result set. """ results = self.get_users(filter='email eq "%s"' % (email)) if resu...
[ "def", "get_user_by_email", "(", "self", ",", "email", ")", ":", "results", "=", "self", ".", "get_users", "(", "filter", "=", "'email eq \"%s\"'", "%", "(", "email", ")", ")", "if", "results", "[", "'totalResults'", "]", "==", "0", ":", "logging", ".", ...
Returns details for user with the given email address. If there is more than one match will only return the first. Use get_users() for full result set.
[ "Returns", "details", "for", "user", "with", "the", "given", "email", "address", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L715-L730
train
PredixDev/predixpy
predix/security/uaa.py
UserAccountAuthentication.get_user
def get_user(self, id): """ Returns details about the user for the given id. Use get_user_by_email() or get_user_by_username() for help identifiying the id. """ self.assert_has_permission('scim.read') return self._get(self.uri + '/Users/%s' % (id))
python
def get_user(self, id): """ Returns details about the user for the given id. Use get_user_by_email() or get_user_by_username() for help identifiying the id. """ self.assert_has_permission('scim.read') return self._get(self.uri + '/Users/%s' % (id))
[ "def", "get_user", "(", "self", ",", "id", ")", ":", "self", ".", "assert_has_permission", "(", "'scim.read'", ")", "return", "self", ".", "_get", "(", "self", ".", "uri", "+", "'/Users/%s'", "%", "(", "id", ")", ")" ]
Returns details about the user for the given id. Use get_user_by_email() or get_user_by_username() for help identifiying the id.
[ "Returns", "details", "about", "the", "user", "for", "the", "given", "id", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/uaa.py#L732-L740
train
PredixDev/predixpy
predix/admin/timeseries.py
TimeSeries.create
def create(self): """ Create an instance of the Time Series Service with the typical starting settings. """ self.service.create() predix.config.set_env_value(self.use_class, 'ingest_uri', self.get_ingest_uri()) predix.config.set_env_value(self.use...
python
def create(self): """ Create an instance of the Time Series Service with the typical starting settings. """ self.service.create() predix.config.set_env_value(self.use_class, 'ingest_uri', self.get_ingest_uri()) predix.config.set_env_value(self.use...
[ "def", "create", "(", "self", ")", ":", "self", ".", "service", ".", "create", "(", ")", "predix", ".", "config", ".", "set_env_value", "(", "self", ".", "use_class", ",", "'ingest_uri'", ",", "self", ".", "get_ingest_uri", "(", ")", ")", "predix", "."...
Create an instance of the Time Series Service with the typical starting settings.
[ "Create", "an", "instance", "of", "the", "Time", "Series", "Service", "with", "the", "typical", "starting", "settings", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/timeseries.py#L31-L46
train
PredixDev/predixpy
predix/admin/timeseries.py
TimeSeries.grant_client
def grant_client(self, client_id, read=True, write=True): """ Grant the given client id all the scopes and authorities needed to work with the timeseries service. """ scopes = ['openid'] authorities = ['uaa.resource'] if write: for zone in self.servic...
python
def grant_client(self, client_id, read=True, write=True): """ Grant the given client id all the scopes and authorities needed to work with the timeseries service. """ scopes = ['openid'] authorities = ['uaa.resource'] if write: for zone in self.servic...
[ "def", "grant_client", "(", "self", ",", "client_id", ",", "read", "=", "True", ",", "write", "=", "True", ")", ":", "scopes", "=", "[", "'openid'", "]", "authorities", "=", "[", "'uaa.resource'", "]", "if", "write", ":", "for", "zone", "in", "self", ...
Grant the given client id all the scopes and authorities needed to work with the timeseries service.
[ "Grant", "the", "given", "client", "id", "all", "the", "scopes", "and", "authorities", "needed", "to", "work", "with", "the", "timeseries", "service", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/timeseries.py#L48-L69
train
PredixDev/predixpy
predix/admin/timeseries.py
TimeSeries.get_query_uri
def get_query_uri(self): """ Return the uri used for queries on time series data. """ # Query URI has extra path we don't want so strip it off here query_uri = self.service.settings.data['query']['uri'] query_uri = urlparse(query_uri) return query_uri.scheme + ':/...
python
def get_query_uri(self): """ Return the uri used for queries on time series data. """ # Query URI has extra path we don't want so strip it off here query_uri = self.service.settings.data['query']['uri'] query_uri = urlparse(query_uri) return query_uri.scheme + ':/...
[ "def", "get_query_uri", "(", "self", ")", ":", "# Query URI has extra path we don't want so strip it off here", "query_uri", "=", "self", ".", "service", ".", "settings", ".", "data", "[", "'query'", "]", "[", "'uri'", "]", "query_uri", "=", "urlparse", "(", "quer...
Return the uri used for queries on time series data.
[ "Return", "the", "uri", "used", "for", "queries", "on", "time", "series", "data", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/timeseries.py#L91-L98
train
PredixDev/predixpy
predix/admin/timeseries.py
TimeSeries.add_to_manifest
def add_to_manifest(self, manifest): """ Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry...
python
def add_to_manifest(self, manifest): """ Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry...
[ "def", "add_to_manifest", "(", "self", ",", "manifest", ")", ":", "# Add this service to list of services", "manifest", ".", "add_service", "(", "self", ".", "service", ".", "name", ")", "# Add environment variables", "uri", "=", "predix", ".", "config", ".", "get...
Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry app.
[ "Add", "useful", "details", "to", "the", "manifest", "about", "this", "service", "so", "that", "it", "can", "be", "used", "in", "an", "application", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/timeseries.py#L100-L125
train
landscapeio/requirements-detector
requirements_detector/detect.py
find_requirements
def find_requirements(path): """ This method tries to determine the requirements of a particular project by inspecting the possible places that they could be defined. It will attempt, in order: 1) to parse setup.py in the root for an install_requires value 2) to read a requirements.txt file or...
python
def find_requirements(path): """ This method tries to determine the requirements of a particular project by inspecting the possible places that they could be defined. It will attempt, in order: 1) to parse setup.py in the root for an install_requires value 2) to read a requirements.txt file or...
[ "def", "find_requirements", "(", "path", ")", ":", "requirements", "=", "[", "]", "setup_py", "=", "os", ".", "path", ".", "join", "(", "path", ",", "'setup.py'", ")", "if", "os", ".", "path", ".", "exists", "(", "setup_py", ")", "and", "os", ".", ...
This method tries to determine the requirements of a particular project by inspecting the possible places that they could be defined. It will attempt, in order: 1) to parse setup.py in the root for an install_requires value 2) to read a requirements.txt file or a requirements.pip in the root 3) to...
[ "This", "method", "tries", "to", "determine", "the", "requirements", "of", "a", "particular", "project", "by", "inspecting", "the", "possible", "places", "that", "they", "could", "be", "defined", "." ]
22cb3fdd6b7f7f6c2eaee40ef8db540ef453b840
https://github.com/landscapeio/requirements-detector/blob/22cb3fdd6b7f7f6c2eaee40ef8db540ef453b840/requirements_detector/detect.py#L67-L118
train
PredixDev/predixpy
predix/admin/cf/apps.py
App.get_app_guid
def get_app_guid(self, app_name): """ Returns the GUID for the app instance with the given name. """ summary = self.space.get_space_summary() for app in summary['apps']: if app['name'] == app_name: return app['guid']
python
def get_app_guid(self, app_name): """ Returns the GUID for the app instance with the given name. """ summary = self.space.get_space_summary() for app in summary['apps']: if app['name'] == app_name: return app['guid']
[ "def", "get_app_guid", "(", "self", ",", "app_name", ")", ":", "summary", "=", "self", ".", "space", ".", "get_space_summary", "(", ")", "for", "app", "in", "summary", "[", "'apps'", "]", ":", "if", "app", "[", "'name'", "]", "==", "app_name", ":", "...
Returns the GUID for the app instance with the given name.
[ "Returns", "the", "GUID", "for", "the", "app", "instance", "with", "the", "given", "name", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/apps.py#L16-L24
train
PredixDev/predixpy
predix/admin/cf/apps.py
App.delete_app
def delete_app(self, app_name): """ Delete the given app. Will fail intentionally if there are any service bindings. You must delete those first. """ if app_name not in self.space.get_apps(): logging.warning("App not found so... succeeded?") retu...
python
def delete_app(self, app_name): """ Delete the given app. Will fail intentionally if there are any service bindings. You must delete those first. """ if app_name not in self.space.get_apps(): logging.warning("App not found so... succeeded?") retu...
[ "def", "delete_app", "(", "self", ",", "app_name", ")", ":", "if", "app_name", "not", "in", "self", ".", "space", ".", "get_apps", "(", ")", ":", "logging", ".", "warning", "(", "\"App not found so... succeeded?\"", ")", "return", "True", "guid", "=", "sel...
Delete the given app. Will fail intentionally if there are any service bindings. You must delete those first.
[ "Delete", "the", "given", "app", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/cf/apps.py#L26-L38
train
PredixDev/predixpy
predix/admin/config.py
ServiceConfig._get_service_config
def _get_service_config(self): """ Reads in config file of UAA credential information or generates one as a side-effect if not yet initialized. """ # Should work for windows, osx, and linux environments if not os.path.exists(self.config_path): try: ...
python
def _get_service_config(self): """ Reads in config file of UAA credential information or generates one as a side-effect if not yet initialized. """ # Should work for windows, osx, and linux environments if not os.path.exists(self.config_path): try: ...
[ "def", "_get_service_config", "(", "self", ")", ":", "# Should work for windows, osx, and linux environments", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "config_path", ")", ":", "try", ":", "os", ".", "makedirs", "(", "os", ".", "path", ...
Reads in config file of UAA credential information or generates one as a side-effect if not yet initialized.
[ "Reads", "in", "config", "file", "of", "UAA", "credential", "information", "or", "generates", "one", "as", "a", "side", "-", "effect", "if", "not", "yet", "initialized", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/config.py#L23-L40
train
PredixDev/predixpy
predix/admin/config.py
ServiceConfig._write_service_config
def _write_service_config(self): """ Will write the config out to disk. """ with open(self.config_path, 'w') as output: output.write(json.dumps(self.data, sort_keys=True, indent=4))
python
def _write_service_config(self): """ Will write the config out to disk. """ with open(self.config_path, 'w') as output: output.write(json.dumps(self.data, sort_keys=True, indent=4))
[ "def", "_write_service_config", "(", "self", ")", ":", "with", "open", "(", "self", ".", "config_path", ",", "'w'", ")", "as", "output", ":", "output", ".", "write", "(", "json", ".", "dumps", "(", "self", ".", "data", ",", "sort_keys", "=", "True", ...
Will write the config out to disk.
[ "Will", "write", "the", "config", "out", "to", "disk", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/config.py#L42-L47
train
PredixDev/predixpy
predix/admin/blobstore.py
BlobStore.create
def create(self, **kwargs): """ Create an instance of the Blob Store Service with the typical starting settings. """ self.service.create(**kwargs) predix.config.set_env_value(self.use_class, 'url', self.service.settings.data['url']) predix.config....
python
def create(self, **kwargs): """ Create an instance of the Blob Store Service with the typical starting settings. """ self.service.create(**kwargs) predix.config.set_env_value(self.use_class, 'url', self.service.settings.data['url']) predix.config....
[ "def", "create", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "service", ".", "create", "(", "*", "*", "kwargs", ")", "predix", ".", "config", ".", "set_env_value", "(", "self", ".", "use_class", ",", "'url'", ",", "self", ".", "ser...
Create an instance of the Blob Store Service with the typical starting settings.
[ "Create", "an", "instance", "of", "the", "Blob", "Store", "Service", "with", "the", "typical", "starting", "settings", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/blobstore.py#L28-L44
train
PredixDev/predixpy
predix/admin/blobstore.py
BlobStore.add_to_manifest
def add_to_manifest(self, manifest): """ Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry...
python
def add_to_manifest(self, manifest): """ Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry...
[ "def", "add_to_manifest", "(", "self", ",", "manifest", ")", ":", "# Add this service to the list of services", "manifest", ".", "add_service", "(", "self", ".", "service", ".", "name", ")", "# Add environment variables", "url", "=", "predix", ".", "config", ".", ...
Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry app.
[ "Add", "useful", "details", "to", "the", "manifest", "about", "this", "service", "so", "that", "it", "can", "be", "used", "in", "an", "application", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/blobstore.py#L46-L75
train
PredixDev/predixpy
predix/data/eventhub/subscriber.py
Subscriber.subscribe
def subscribe(self): """ return a generator for all subscribe messages :return: None """ while self.run_subscribe_generator: if len(self._rx_messages) != 0: yield self._rx_messages.pop(0) return
python
def subscribe(self): """ return a generator for all subscribe messages :return: None """ while self.run_subscribe_generator: if len(self._rx_messages) != 0: yield self._rx_messages.pop(0) return
[ "def", "subscribe", "(", "self", ")", ":", "while", "self", ".", "run_subscribe_generator", ":", "if", "len", "(", "self", ".", "_rx_messages", ")", "!=", "0", ":", "yield", "self", ".", "_rx_messages", ".", "pop", "(", "0", ")", "return" ]
return a generator for all subscribe messages :return: None
[ "return", "a", "generator", "for", "all", "subscribe", "messages", ":", "return", ":", "None" ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/subscriber.py#L97-L105
train
PredixDev/predixpy
predix/data/eventhub/subscriber.py
Subscriber.send_acks
def send_acks(self, message): """ send acks to the service :param message: EventHub_pb2.Message :return: None """ if isinstance(message, EventHub_pb2.Message): ack = EventHub_pb2.Ack(partition=message.partition, offset=message.offset) self.grpc_man...
python
def send_acks(self, message): """ send acks to the service :param message: EventHub_pb2.Message :return: None """ if isinstance(message, EventHub_pb2.Message): ack = EventHub_pb2.Ack(partition=message.partition, offset=message.offset) self.grpc_man...
[ "def", "send_acks", "(", "self", ",", "message", ")", ":", "if", "isinstance", "(", "message", ",", "EventHub_pb2", ".", "Message", ")", ":", "ack", "=", "EventHub_pb2", ".", "Ack", "(", "partition", "=", "message", ".", "partition", ",", "offset", "=", ...
send acks to the service :param message: EventHub_pb2.Message :return: None
[ "send", "acks", "to", "the", "service", ":", "param", "message", ":", "EventHub_pb2", ".", "Message", ":", "return", ":", "None" ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/subscriber.py#L107-L121
train
PredixDev/predixpy
predix/data/eventhub/subscriber.py
Subscriber._generate_subscribe_headers
def _generate_subscribe_headers(self): """ generate the subscribe stub headers based on the supplied config :return: i """ headers =[] headers.append(('predix-zone-id', self.eventhub_client.zone_id)) token = self.eventhub_client.service._get_bearer_token() ...
python
def _generate_subscribe_headers(self): """ generate the subscribe stub headers based on the supplied config :return: i """ headers =[] headers.append(('predix-zone-id', self.eventhub_client.zone_id)) token = self.eventhub_client.service._get_bearer_token() ...
[ "def", "_generate_subscribe_headers", "(", "self", ")", ":", "headers", "=", "[", "]", "headers", ".", "append", "(", "(", "'predix-zone-id'", ",", "self", ".", "eventhub_client", ".", "zone_id", ")", ")", "token", "=", "self", ".", "eventhub_client", ".", ...
generate the subscribe stub headers based on the supplied config :return: i
[ "generate", "the", "subscribe", "stub", "headers", "based", "on", "the", "supplied", "config", ":", "return", ":", "i" ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/subscriber.py#L123-L153
train
PredixDev/predixpy
predix/ie/parking.py
ParkingPlanning._get_assets
def _get_assets(self, bbox, size=None, page=None, asset_type=None, device_type=None, event_type=None, media_type=None): """ Returns the raw results of an asset search for a given bounding box. """ uri = self.uri + '/v1/assets/search' headers = self._get_header...
python
def _get_assets(self, bbox, size=None, page=None, asset_type=None, device_type=None, event_type=None, media_type=None): """ Returns the raw results of an asset search for a given bounding box. """ uri = self.uri + '/v1/assets/search' headers = self._get_header...
[ "def", "_get_assets", "(", "self", ",", "bbox", ",", "size", "=", "None", ",", "page", "=", "None", ",", "asset_type", "=", "None", ",", "device_type", "=", "None", ",", "event_type", "=", "None", ",", "media_type", "=", "None", ")", ":", "uri", "=",...
Returns the raw results of an asset search for a given bounding box.
[ "Returns", "the", "raw", "results", "of", "an", "asset", "search", "for", "a", "given", "bounding", "box", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/ie/parking.py#L85-L146
train
PredixDev/predixpy
predix/ie/parking.py
ParkingPlanning.get_assets
def get_assets(self, bbox, **kwargs): """ Query the assets stored in the intelligent environment for a given bounding box and query. Assets can be filtered by type of asset, event, or media available. - device_type=['DATASIM'] - asset_type=['CAMERA'] ...
python
def get_assets(self, bbox, **kwargs): """ Query the assets stored in the intelligent environment for a given bounding box and query. Assets can be filtered by type of asset, event, or media available. - device_type=['DATASIM'] - asset_type=['CAMERA'] ...
[ "def", "get_assets", "(", "self", ",", "bbox", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_get_assets", "(", "bbox", ",", "*", "*", "kwargs", ")", "# Remove broken HATEOAS _links but identify asset uid first", "assets", "=", "[", "]", ...
Query the assets stored in the intelligent environment for a given bounding box and query. Assets can be filtered by type of asset, event, or media available. - device_type=['DATASIM'] - asset_type=['CAMERA'] - event_type=['PKIN'] - media_type=['IMAGE'] ...
[ "Query", "the", "assets", "stored", "in", "the", "intelligent", "environment", "for", "a", "given", "bounding", "box", "and", "query", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/ie/parking.py#L148-L188
train
PredixDev/predixpy
predix/ie/parking.py
ParkingPlanning._get_asset
def _get_asset(self, asset_uid): """ Returns raw response for an given asset by its unique id. """ uri = self.uri + '/v2/assets/' + asset_uid headers = self._get_headers() return self.service._get(uri, headers=headers)
python
def _get_asset(self, asset_uid): """ Returns raw response for an given asset by its unique id. """ uri = self.uri + '/v2/assets/' + asset_uid headers = self._get_headers() return self.service._get(uri, headers=headers)
[ "def", "_get_asset", "(", "self", ",", "asset_uid", ")", ":", "uri", "=", "self", ".", "uri", "+", "'/v2/assets/'", "+", "asset_uid", "headers", "=", "self", ".", "_get_headers", "(", ")", "return", "self", ".", "service", ".", "_get", "(", "uri", ",",...
Returns raw response for an given asset by its unique id.
[ "Returns", "raw", "response", "for", "an", "given", "asset", "by", "its", "unique", "id", "." ]
a0cb34cf40f716229351bb6d90d6ecace958c81f
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/ie/parking.py#L190-L198
train
djgagne/hagelslag
hagelslag/processing/Hysteresis.py
Hysteresis.label
def label(self, input_grid): """ Label input grid with hysteresis method. Args: input_grid: 2D array of values. Returns: Labeled output grid. """ unset = 0 high_labels, num_labels = label(input_grid > self.high_thresh) region_rank...
python
def label(self, input_grid): """ Label input grid with hysteresis method. Args: input_grid: 2D array of values. Returns: Labeled output grid. """ unset = 0 high_labels, num_labels = label(input_grid > self.high_thresh) region_rank...
[ "def", "label", "(", "self", ",", "input_grid", ")", ":", "unset", "=", "0", "high_labels", ",", "num_labels", "=", "label", "(", "input_grid", ">", "self", ".", "high_thresh", ")", "region_ranking", "=", "np", ".", "argsort", "(", "maximum", "(", "input...
Label input grid with hysteresis method. Args: input_grid: 2D array of values. Returns: Labeled output grid.
[ "Label", "input", "grid", "with", "hysteresis", "method", "." ]
6fb6c3df90bf4867e13a97d3460b14471d107df1
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/Hysteresis.py#L20-L49
train
djgagne/hagelslag
hagelslag/processing/Hysteresis.py
Hysteresis.size_filter
def size_filter(labeled_grid, min_size): """ Remove labeled objects that do not meet size threshold criteria. Args: labeled_grid: 2D output from label method. min_size: minimum size of object in pixels. Returns: labeled grid with smaller objects remo...
python
def size_filter(labeled_grid, min_size): """ Remove labeled objects that do not meet size threshold criteria. Args: labeled_grid: 2D output from label method. min_size: minimum size of object in pixels. Returns: labeled grid with smaller objects remo...
[ "def", "size_filter", "(", "labeled_grid", ",", "min_size", ")", ":", "out_grid", "=", "np", ".", "zeros", "(", "labeled_grid", ".", "shape", ",", "dtype", "=", "int", ")", "slices", "=", "find_objects", "(", "labeled_grid", ")", "j", "=", "1", "for", ...
Remove labeled objects that do not meet size threshold criteria. Args: labeled_grid: 2D output from label method. min_size: minimum size of object in pixels. Returns: labeled grid with smaller objects removed.
[ "Remove", "labeled", "objects", "that", "do", "not", "meet", "size", "threshold", "criteria", "." ]
6fb6c3df90bf4867e13a97d3460b14471d107df1
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/Hysteresis.py#L52-L72
train