Adobe IO : Launch API : Core Components

In this article, I will look at the different method available from the pylaunch module, the ones directly available without any class instantiation.
At the bottom of this page you will find some code examples on how to use these methods-

Pylaunch Initiator

The first methods that are available from the pylaunch module and that you should know are:

createConfigFile

This will create a json file that you will need to file with the different element requested to generate the token (API Key, Secret, Technical Account, Path to your private key).
Once you have set up this configuration, you can actually call the 2nd method.

importConfigFile

This is taking the name of your config file (or path to it) in order to open it and read it.
This will set the variable required to generate the token.

retrieveToken

This method is actually generating a token. It can be used once you have actually set up your config file and import it into your environment.

getCompanyId

This method will return the company ID from your adobe IO connector. Your token are usually generated for only one company and this is returning which company you are allowed to look for.

getProperties

This method takes one argument (the company id) and it will return a list of property that you will be able to feed the Property class.

Pylaunch creator

Pylaunch also provide a method to create a property. This method can return an instance of the Property class directly.

createProperty

It returns either the instance of the Property class or the object returned by the API.
It takes several arguments:

  • the company id
  • a name
  • the platform (by default it is web)
  • return_class : a Boolean if you want to return an instance of the Property class.

There are certain kwargs that are also allowed (domains, development, or undefined_vars_return_empty)
reference here : https://developer.adobelaunch.com/api/reference/1.0/properties/create/

Pylaunch Facilitator

The core methods have some facilitators methods that should help you along the way of using this API. Those facilitators are the real bonus of this wrapper and I hope you will understand how to use them.

The Info methods

There are 4 different methods that are actually giving you around the same information about the different component of Launch:

  • extensionsInfo
  • rulesInfo
  • dataElementInfo
  • ruleComponentInfo

Those 4 methods are taking their different elements lists, the ones returned by the getRules, getExtensions, etc… methods and they return a dictionary of name and their attributes. You can create a pandas dataframe from that dictionary and that can help you creating a report for your different elements.

The different attributes retrieve by these functions are :

  • name
  • data of the creation
  • date of the update
  • id
  • delegate descriptor id (except for rules)
  • Publish state
  • Working state (dirty)
  • review status
  • revision number
  • version
  • settings (except for rules)
  • id
  • extension id (for Extension)
  • rule order (for rule component)

CopySettings

This method allows you to copy settings from one element (Data Element, Extension, Rules, Rule Component) and returns the settings required to create the element again.
One of my main use case would be to copy paste element from one property to another. Thanks to that function, the required elements can be easily catch in a loop on all of your elements.

Note : Think that you don’t need to recreate a Core Extension because it created by default.

extractSettings

This function let’s you extract the settings of your elements. It doesn’t work on rules because rules’ settings are actually set in the rule component elements.
So you can actually extract the settings for the Extensions, the data elements and the rule components.

  • extractSettings
    Extract the settings from your element. For your custom code, it will extract the javaScript.
    Arguments:
    • element : REQUIRED : element from which you would like to extract the setting from.
    • save : OPTIONAL : bool, if you want to save the setting in a JS or JSON file, set it to true. (default False)

Note : for the Custom Code of the Core elements (Data Elements, Rule Component Condition, Rule Component Event, Rule Component Action) it will retrieve the code in a JS file.
For all of the other element type, it returns a JSON format of their settings.

extractAttributes

The method Extract attributes will extract the overall attributes of your element (name, enabled or not, created at, published or not, etc…)
This method is quite interesting if you would like to change the one of the setting (it is a dictionary) and re-import it through an update method.

  • extractAttributes
    Extract the attributes of your element. You can save it in a file as well.
    Arguments:
    • element : REQUIRED : element you want to get the attributes from
    • save : OPTIONAL : bool, if you want to save the setting in a JS or JSON file, set it to true. (default False)

duplicateAttributes

This method is copy pasting the setting of one element to another one. You need to provide the elements as a list (for the base element and the target elements), however it can be a list of one element.
It will copy the base element setting and paste it to the target element. It can also do that for other attributes than settings. It is set through a kwargs.

  • duplicateAttributes
    Take a list of element and copy their settings (default) to another list of element. Returns a new list of the elements attributes.
    Arguments:
    • base_elements : REQUIRED : list of elements you want to copy
    • target_elements : REQUIRED : list of elements you want to change
  • Possible kwargs :
    • key : OPTIONAL : the type of element you want to copy paste (settings, name,enabled ,etc…). default value for the key are “settings”.
    • name_filter : OPTIONAL : Filter the elements to copy to only the ones containing the string in the filter.
      example : name_filter=’analytics’ will only copy the element that has analytics in their name

Code Example

I hope this post helps you to better understand the pylaunch core component methods.
You may be interested in the articles that explains a bit more about the different components of the pylaunch module.

ArticlesComments
Adobe IO : JWT authenticationHow to create JWT authentication with OpenSSL and python
Adobe IO : Launch API : Introduction to pylaunchWhat you need to know about this module
Adobe IO : Launch API : Core Component The methods directly available from this module.
Adobe IO : Launch API : Property ClassWhat is the Property class and how to use it to manage your Launch properties
Adobe IO : Launch API : Library ClassHow to manage your publishing process through pylaunch, in python
Adobe IO : Launch API : Translator ClassA Facilitator in pylaunch in order to copy paste the element from one property to another.
Adobe IO : Launch API : TutorialVideo tutorial on some methods available from the pylaunch module. Not everything is covered in the video.

Leave a Reply

Your email address will not be published. Required fields are marked *