Exemplo n.º 1
0
 def getStats(self):
     """
     Returns a list of the last actions realized on the Schema for this instance of AEP. 
     """
     path = '/stats/'
     res = aepp._getData(self.endpoint+path, headers=self.header)
     return res
Exemplo n.º 2
0
 def getMixins(self):
     """
     returns the mixin of the account
     """
     path = '/tenant/mixins/'
     res = aepp._getData(self.endpoint+path, headers=self.header)
     return res
Exemplo n.º 3
0
 def getXDMprofileSchema(self):
     """
     Returns a list of all schemas that are part of the XDM Individual Profile.
     """
     path = "/tenant/schemas?property=meta:immutableTags==union&property=meta:class==https://ns.adobe.com/xdm/context/profile"
     res = aepp._getData(self.endpoint + path, headers=self.header)
     return res
Exemplo n.º 4
0
 def getSchema(self, schema_id: str = None, version: int = 1, save: bool = False, findPaths: bool = False, **kwargs):
     """
     Get the Schema. Requires a schema id.
     Response provided depends on the header set, you can change the Accept header with kwargs.
     Arguments:
         schema_id : REQUIRED : $id or meta:altId
         version : OPTIONAL : Version of the Schema asked (default 1)
         save : OPTIONAL : save the result in json file (default False)
         findPaths : find the paths present in your schema.
     Possible kwargs:
         Accept : Accept header to change the type of response.
         # /Schemas/lookup_schema
         more details held here : https://www.adobe.io/apis/experienceplatform/home/api-reference.html
     """
     self.header["Accept"] = "application/vnd.adobe.xed-full+json; version=" + \
         str(version)
     if kwargs.get('Accept', None) is not None:
         header['Accept'] = kwargs.get('Accept', header['Accept'])
     self.header['Accept-Encoding'] = 'identity'
     if schema_id.startswith('https://'):
         from urllib import parse
         schema_id = parse.quote_plus(schema_id)
     path = f'/tenant/schemas/{schema_id}'
     res = aepp._getData(self.endpoint + path)
     del self.header['Accept-Encoding']
     self.header['Accept'] = "application/json"
     if save:
         with open(f'{res["title"]}.json', 'w') as f:
             f.write(aepp.json.dumps(res, indent=4))
     self.schemas[res['title']] = res
     if findPaths:
         paths = self._getPaths(res)
         self.schemasPaths[res['title']] = paths
     return res
Exemplo n.º 5
0
 def getClasses(self):
     """
     return the classes of the AEP Instances.
     """
     path = '/tenant/classes/'
     res = aepp._getData(self.endpoint+path, headers=self.header)
     return res
Exemplo n.º 6
0
 def getSchemas(self):
     """
     Returns a lit of the schemas hosted in this instance.
     """
     path = '/tenant/schemas/'
     res = aepp._getData(self.endpoint+path, headers=self.header)
     data = res['results']
     return data
Exemplo n.º 7
0
 def getDataSet(self, dataset_id: str = None):
     """
     Return a single dataset.
     Arguments:
         dataset_id : REQUIRED : Id of the dataset to be retrieved.
     """
     if dataset_id is None:
         raise Exception("Expected a dataset_id argument")
     path = f"/dataSets/{dataset_id}"
     res = aepp._getData(self.endpoint + path, headers=self.header)
     return res
Exemplo n.º 8
0
 def getConnectionDataSets(self, connection_id: str = None):
     """
     Return the dataSet attached to the conenction
     Arguments:
         connection_id : REQUIRED : ID of the connection.
     """
     if connection_id is None:
         raise Exception("Expected connection connection_id as argument")
     path = f"/connections/{connection_id}/dataSets"
     res = aepp._getData(self.endpoint + path, headers=self.header)
     return res
Exemplo n.º 9
0
 def getConnection(self, connection_id: str = None):
     """
     Retrieve a specific connection
     Arguments:
         connection_id : REQUIRED : ID of the connection to retrieve. 
     """
     if connection_id is None:
         raise Exception("Expected a connection_id parameter")
     path = f"/connections/{connection_id}"
     res = aepp._getData(self.endpoint + path, headers=self.header)
     return res
Exemplo n.º 10
0
 def getConnectorStats(self, connector_id: str = None):
     """
     Retrieve the stats for a specific connector.
     Arguments:
         connector_id : REQUIRED : connector id for the connector stats to be retrieved. 
     """
     if connector_id is None:
         raise Exception("Expected a connector_id parameter.")
     path = f"/connectors/{connector_id}/stats"
     res = aepp._getData(self.endpoint + path, headers=self.header)
     return res
Exemplo n.º 11
0
 def getAccount(self, account_id: str = None):
     """
     Get a specific Account based on the id.
     Arguments:
         account_id : REQUIRED : object ID
     """
     if account_id is None:
         raise Exception("Require an account_id")
     path = f"/accounts/{account_id}"
     res = aepp._getData(self.endpoint + path, headers=self.header)
     return res
Exemplo n.º 12
0
 def getBatch(self, batch_id: str = None):
     """
     Get a specific batch id.
     Arguments: 
         batch_id : REQUIRED : batch ID to be retrieved. 
     """
     if batch_id is None:
         raise Exception("batch_id parameter is required.")
     path = f"/batches/{batch_id}"
     res = aepp._getData(self.endpoint + path, headers=self.header)
     return res
Exemplo n.º 13
0
 def getDataSetView(self, dataset_id: str = None, view_id: str = None):
     """
     Get a specific view on a specific dataset.
     Arguments:
         dataset_id : REQUIRED : ID of the dataset to be looked down.
         view_id : REQUIRED : ID of the view to be look upon.
     """
     if dataset_id is None or view_id is None:
         raise Exception("Expected a dataset_id and an view_id argument")
     path = f"dataSets/{dataset_id}/views/{view_id}"
     res = aepp._getData(self.endpoint + path, headers=self.header)
     return res
Exemplo n.º 14
0
 def getDataSetViewFiles(self, dataset_id: str = None, view_id: str = None):
     """
     Returns the list of files attached to a view in a Dataset.
     Arguments:
         dataset_id : REQUIRED : ID of the dataset to be looked down.
         view_id : REQUIRED : ID of the view to be look upon.
     """
     if dataset_id is None or view_id is None:
         raise Exception("Expected a dataset_id and an view_id argument")
     path = f"dataSets/{dataset_id}/views/{view_id}/files"
     res = aepp._getData(self.endpoint + path, headers=self.header)
     return res
Exemplo n.º 15
0
 def getConnector(self, connector_id: str = None, stats: bool = False):
     """
     Returns a scpecific connector details and its stats if required in the parameter.
     Arguments:
         connector_id : REQUIRED : connector id for the connector to be retrieved. 
         stats : OPTIONAL : If set to True, return a 2nd object with the stat of the connector.
     """
     if connector_id is None:
         raise Exception("Expected a connector_id parameter.")
     path = f"/connectors/{connector_id}"
     res = aepp._getData(self.endpoint + path, headers=self.header)
     if stats == False:
         return res
     elif stats:
         stats = self.getConnectorStats(connector_id)
         return res, stats
Exemplo n.º 16
0
 def getDataSetViews(self, dataset_id: str = None, **kwargs):
     """
     Get views of the datasets.
     Arguments:
         dataset_id : REQUIRED : Id of the dataset to be looked down.
     Possible kwargs:
         limit : Limit response to a specified positive number of objects. Ex. limit=10
         orderBy : Sort parameter and direction for sorting the response. Ex. orderBy=asc:created,updated.
         start : Returns results from a specific offset of objects. This was previously called offset. Ex. start=3.
         property : Regex used to filter objects in the response. Ex. property=name~^test.
     """
     if dataset_id is None:
         raise Exception("Expected a dataset_id argument")
     path = f"dataSets/{dataset_id}/views"
     params = {**kwargs}
     res = aepp._getData(self.endpoint + path, headers=self.header)
     return res
Exemplo n.º 17
0
 def getConnectors(self, **kwargs):
     """
     Returns the list of connectors
     Possible kwargs:
         name : Filter by the name of this Connector.
         type : Filter by the ingest type for this Connector.
         category : Connectors currently have 2 categories: 1) standard: we are connecting to a known source with known data (ie. other companies data stores) or 2) custom: a generic connector to FTP or S3 etc.
         limit : Limit response to a specified positive number of objects. Ex. limit=10
         version : Filter by Semantic version of the account. Updated when the object is modified.
         property : Regex used to filter objects in the response. Ex. property=name~^test.
     """
     path = "/connectors"
     params = {**kwargs}
     res = aepp._getData(self.endpoint + path,
                         headers=self.header,
                         params=params)
     return res
Exemplo n.º 18
0
 def getAccounts(self, **kwargs):
     """
     Returns the list of all account.
     Possible kwargs:
         connector : The ID for the Connector this Account params was created from
         description : Filter by user-provided description of the account.
         version : Filter by Semantic version of the account. Updated when the object is modified.
         created : Filter by the Unix timestamp (in milliseconds) when this object was persisted.
         updated : Filter by the Unix timestamp (in milliseconds) for the time of last modification.
         createdUser : Filter by the ID of the user who created this object.
         property : Regex used to filter objects in the response. Ex. property=name~^test.
     more details : https://www.adobe.io/apis/experienceplatform/home/api-reference.html#/Accounts/get_accounts
     """
     path = "/accounts/"
     params = {**kwargs}
     res = aepp._getData(self.endpoint + path,
                         headers=self.header,
                         params=params)
     return res
Exemplo n.º 19
0
 def getDataSets(self, **kwargs):
     """
     Return a list of a datasets.
     Possible kwargs:
         state : The state related to a dataset.
         created : Filter by the Unix timestamp (in milliseconds) when this object was persisted.
         updated : Filter by the Unix timestamp (in milliseconds) for the time of last modification.
         name : Filter by the a descriptive, human-readable name for this DataSet.
         namespace : One of the registered platform acronyms that identify the platform.
         version : Filter by Semantic version of the account. Updated when the object is modified.
         property : Regex used to filter objects in the response. Ex. property=name~^test.
         more possibilities : https://www.adobe.io/apis/experienceplatform/home/api-reference.html#/Datasets/get_data_sets
     """
     path = "/dataSets"
     params = {**kwargs}
     res = aepp._getData(self.endpoint + path,
                         headers=self.header,
                         params=params)
     return res
Exemplo n.º 20
0
 def getUnion(self, union_id: str = None, version: int = 1):
     """
     Get a specific union type. Returns a dictionnary
     Arguments :
         union_id : REQUIRED :  meta:altId or $id
         version : OPTIONAL : version of the union schema required.
     """
     if union_id is None:
         raise Exception("Require an ID")
     if union_id.startswith('https://'):
         from urllib import parse
         union_id = parse.quote_plus(union_id)
     path = f'/tenant/unions/{union_id}'
     self.header.update({
         "Accept": "application/vnd.adobe.xed-full+json; version="+str(version)})
     res = aepp._getData(self.endpoint + path, headers=self.header)
     self.header.update({
         "Accept": "application/json"})
     return res
Exemplo n.º 21
0
    def getUnions(self, **kwargs):
        """
        Get all of the unions that has been set for the tenant.
        Returns a dictionary.

        Possibility to add option using kwargs
        """
        path = '/tenant/unions'
        params = {}
        if len(kwargs) > 0:
            for key in kwargs.key():
                if key == 'limit':
                    if int(kwargs['limit']) > 500:
                        kwargs['limit'] = 500
                params[key] = kwargs.get(key, '')
        res = aepp._getData(self.endpoint+path,
                            params=params, headers=self.header)
        data = res['results']  # issue when requesting directly results.
        return data
Exemplo n.º 22
0
 def getConnections(self, **kwargs):
     """
     Returns list of connections.
     Possible kwargs:
         connector : Filter by the ID for the Connector this Connection was created from.
         parentConnectionId : Used in cases where global/shared data is managed by this connection. The parent connection performs the ETL/Mapping jobs, and this child connection represents a customer’s membership and visibility into the parent.
         name : Filter by the user-facing name of this Connection.
         accountId : Filter by the foreign key to the account where the credentials and related fields of the connector and connection combination is stored.
         description : Filter by the user-provided description of the Connection.
         enabled : Indicates the status of the Connection. Should be interpreted as disabled or suspended when set to false.
         created : Filter by the Unix timestamp (in milliseconds) when this object was persisted.
         limit : Limit response to a specified positive number of objects. Ex. limit=10
     More info can be found here : https://www.adobe.io/apis/experienceplatform/home/api-reference.html#/Connections/get_connections
     """
     path = "/connections"
     params = {**kwargs}
     res = aepp._getData(self.endpoint + path,
                         headers=self.header,
                         params=params)
     return res
Exemplo n.º 23
0
 def getMixin(self, mixin_id: str = None, version: int = 1):
     """
     Returns a specific mixin.
     Arguments:
         mixin_id : meta:altId or $id
         version : version of the mixin
     """
     header = self.header
     if mixin_id.startswith('https://'):
         from urllib import parse
         mixin_id = parse.quote_plus(mixin_id)
     self.header['Accept-Encoding'] = 'identity'
     self.header.update({
         "Accept": "application/vnd.adobe.xed-full+json; version="+str(version)})
     path = f'/tenant/mixins/{mixin_id}'
     res = aepp._getData(self.endpoint + path, headers=header)
     del header['Accept-Encoding']
     self.header.update({
         "Accept": "application/json"})
     return res
Exemplo n.º 24
0
 def getBatches(self, **kwargs):
     """
     Retrieve a list of batches.
     Possible kwargs:
         created : Filter by the Unix timestamp (in milliseconds) when this object was persisted.
         createdAfter : Filter by the Unix timestamp (in milliseconds) when this object was persisted.
         limit : Limit response to a specified positive number of objects. Ex. limit=10
         updated : Filter by the Unix timestamp (in milliseconds) for the time of last modification.
         createdUser : Filter by the ID of the user who created this object.
         dataSet : Used to filter on the related object: &dataSet=dataSetId.
         version : Filter by Semantic version of the account. Updated when the object is modified.
         property : Regex used to filter objects in the response. Ex. property=name~^test.
     more details : https://www.adobe.io/apis/experienceplatform/home/api-reference.html#/Batches/get_batch
     """
     path = "/batches"
     params = {**kwargs}
     res = aepp._getData(self.endpoint + path,
                         headers=self.header,
                         params=params)
     return res
Exemplo n.º 25
0
 def getClass(self, class_id: str = None, version: int = 1):
     """
     Return a specific class.
     Arguments: 
         class_id : REQUIRED : the meta:altId or $id from the class
         version : OPTIONAL : the version of the class to retrieve.
     """
     if class_id is None:
         raise Exception("Require a class_id")
     header = self.header
     if class_id.startswith('https://'):
         from urllib import parse
         class_id = parse.quote_plus(class_id)
     self.header['Accept-Encoding'] = 'identity'
     self.header.update({
         "Accept": "application/vnd.adobe.xed-full+json; version="+str(version)})
     path = f'/tenant/classes/{class_id}'
     res = aepp._getData(self.endpoint + path, headers=header)
     del header['Accept-Encoding']
     self.header.update({
         "Accept": "application/json"})
     return res
Exemplo n.º 26
0
 def getClusterHistory(self,
                       xid: str = None,
                       nsid: int = 411,
                       namespace: str = "adcloud",
                       id_value: str = None,
                       graphType: str = "private") -> dict:
     """
     Given an XID, return all cluster associations with that XID. 
     It is required to pass either xid or (namespace/nsid & id) pair to get cluster history.
     Arguments:
         xid : REQUIRED : Identity string returns by the getIdentity method.
         nsid : OPTIONAL : namespace id (default : 411)
         namespace : OPTIONAL : namespace code. (default : adcloud)
         id_value : OPTIONAL : ID of the customer in given namespace.
         graphType : OPTIONAL : Graph type (output type) you want to get the cluster from. (default private)
     """
     temp_header = deepcopy(self.header)
     temp_header[
         'Accept'] = "application/vnd.adobe.identity+json;version=1.2"
     temp_header['x-uis-cst-ctx'] = "stub"
     path = "/identity/cluster/history"
     params = {}
     if xid is not None:
         params['xid'] = xid
         params['graph-type'] = graphType
         res = aepp._getData(self.endpoint + path,
                             params=params,
                             headers=temp_header)
         return res
     elif xid is None and id_value is not None:
         params['nsid'] = nsid
         params['namespace'] = namespace
         params['id'] = id_value
         params['graph-type'] = graphType
         res = self.connector.getData(self.endpoint + path,
                                      params=params,
                                      headers=temp_header)
         return res