Adobe IO : Launch API : Library Class

EDIT : Change in the documentation has been made. pylaunch is now called launchpy. You can now install it with pip command, doing :
pip install launchpy

The Library class will enable you to manage your Library workflow through python directly. You will be able to add elements to the library, build the library, attach environment or reject the library workflow.

By default the library instance is always going to move forward except if you set the require element.
The Library instance has several attributes that should help you understand at which state the library is actually at.

Create a Library Instance

There are 2 methods to create a library instance :

You can create a library instance by using the Library class method from launchpy, this method requires that you take one of the element returned by the getLibraries method.

You can just create a library from scratch and by default, the createLibrary method will return you an instance of the Library method.

code example:

Library attributes

The instance you have created possess several attributes that can give you interesting information.
The different attributes are the following:

  • id : id of the library
  • name : name of the library
  • state : is it “development”, “staging” or “production” environment
  • build_required : is a build required or not (Boolean)
  • builds : The build attache to this library
  • buid_status : Is the last build has been “successful” ?
  • relationships : the different element attached to this Library
  • _environments = a dictionary of the different environment possible.

The get methods

The get methods will enable you to retrieve the elements that have been attached to this library.
It can help you listing the elements that are going to be tested and / or pushed to the build, and to the production system at the end.

The different get methods are the followings:

  • getDataElements
  • getExtensions
  • getRules
  • getFullLibrary : It is a combinaison of all of the 3 above.

These methods are editing the relationships attributes. You can then manage the elements from there.

The add methods

As you can imagine, the add methods will permit to add elements to the Library itself.
The add methods takes a list of ids as arguments.
They are the following:

  • addDataElements
    Take a list of data elements id and attach them to the library.
    • data_element_ids: REQUIRED : list of data elements id
  • addRules
    Take a list of rules id and attach them to the library.
    • rules_ids: REQUIRED : list of rules id
  • addExtensions
    Take a list of extension id and attach them to the library.
    • extensions_ids: REQUIRED : list of extension

Environments settings

Before you can actually start building the library and pass it from one state to another (“development” -> “staging”). You would need to set the different environments.
You can do so by passing a list of those environments.

  • setEnvironments
    Save the different environments ids available.
    It is required to use the library class.
    • environments_list : REQUIRED : list of environment retrieved by the getEnvironment method
    • dev_name : OPTIONAL : Name of your dev environment. If not defined, will take the first dev environment.

Code example :

Building the library

You will need to build your library before pushing it to different state.
In order to do that, you have a very simple method available : build().

Code example :

Transition your library

As it is your goal to publish your library, you want to transition it from the dev to the staging environment and so forth.
In order to do that, you can use the transition method.
Note that you would need to build your library between 2 transition.
At the end of the funnel, you just need to build your library when you are in the “approved” state.

Complete documentation of the cases :

  • transition
    Move the library along the publishing funnel.
    If no action is provided, it would automatically go to the next state.
    • action : OPTIONAL : action to do on the library. Possible values:
      • ‘submit’ : if state == development
      • ‘approve’ : if state == submitted
      • ‘reject’ : if state == submitted

I hope that this article gave you a good view on how the Library class work.
You may have already noticed that there is no method for removing elements from the library. At the moment, I don’t have the need for this kind of method as I am copy pasting the element from one property to another.
If you would like to develop such method, feel free to participate on this project, otherwise I will probably develop it when I need it.

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

Adobe IO : JWT authenticationHow to create JWT authentication with OpenSSL and python
Adobe IO : Launch API : Introduction to launchpyWhat 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 launchpy, in python
Adobe IO : Launch API : Translator ClassA Facilitator in launchpy in order to copy paste the element from one property to another.
Adobe IO : Launch API : TutorialVideo tutorial on some methods available from the launchpy module. Not everything is covered in the video.

Leave a Reply

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