Adobe IO : Launch API : Property Class

This article will dig into the Property class and what is possible to realize from the instances that are created from that class.
This Class helps you managing your property from the python wrapper directly. You will have 3 main methods from that class;

  • Get
  • Create
  • Delete

There are also some other methods that are available and we will review them in the following paragraph.
You can start by creating an instance of the Property class by doing the following :

The get methods

When you have your property instance created, the methods that you may want to call first are the get methods. They never take any argument, they don’t actually need any argument.
The only thing important to know is that you must run the getRules() method before the getRuleComponents() method.

The different get methods are the following :

  • getEnvironments
  • getHost
  • getExtensions
  • getRules
  • getRuleComponents
  • getDataElements
  • getLibraries

They will always returns you a list of the elements you are requesting.
You can add to these methods 2 additional methods that are more search than get:

  • searchRules
    Returns the rules searched through the different operator. One argument is required in order to return a result.
    Arguments:
    • name : OPTIONAL : string of what is searched (used as “contains”)
    • enabled : OPTIONAL : boolean if search for enabled rules or not
    • published : OPTIONAL : boolean if search for published rules or not
    • dirty : OPTIONAL : boolean if search for dirty rules or not
  • searchDataElements
    Returns the rules searched through the different operator. One argument is required in order to return a result.
    Arguments:
    • name : OPTIONAL : string of what is searched (used as “contains”)
    • enabled : OPTIONAL : boolean if search for enabled rules or not
    • published : OPTIONAL : boolean if search for published rules or not
    • dirty : OPTIONAL : boolean if search for dirty rules or not

These 2 methods will also returns a list of the result.

As an example, and based on the first example I gave at the top of the page, here is how you can call the getRules methods.

The create methods

One of the option of the Property is to create elements directly into Launch.
Even if it is not that easy to create element from the API, easier to modify it, the possibility also exists that you want to create something.
The creates methods exist for that :

  • createExtensions
    Create an extension in your property. Your extension_id argument should be the latest one extension id available.
    Arguments:
    • extension_id : REQUIRED : ID for the extension to be created
    • settings : OPTIONAL: setting to set in the extension
    • delegate_descriptor_id : OPTIONAL : delegate descriptor id
  • createRules
    Create a rule by provided a rule name.
    Arguments:
    • name : REQUIRED : name of your rule.
  • createRuleComponents
    Create a ruleComponent by provided a rule name and descriptor (minimum). It returns an object. It takes additional information in order to link the ruleCompoment to a rule and with an Extension.
    Arguments:
    • name : REQUIRED : name of the rule component
    • descriptor : REQUIRED : delegate_descriptor_id for the rule component
    • extension_id : REQUIRED : Extension used for that rule component (dictionary)
    • rule_id : REQUIRED : rule information link to that rule component (dictionary)
    • settings : OPTIONAL : settings for that rule component
  • createDataElements
    Create Data Elements following the usage of required arguments.
    Arguments:
    • name : REQUIRED : name of the data element
    • descriptor : REQUIRED : delegate_descriptor_id for the data element
    • extension : REQUIRED : extension id used for the data element. (dictionary)
    • settings : OPTIONAL : settings for the data element
  • createEnvironment
    Create an environment. Note that you cannot create more than 1 environment for Staging and Production stage.
    Arguments:
    • name : REQUIRED : name of your environment
    • host_id : REQUIRED : The host id that you would need to connect to the correct host.
    • stage : OPTIONAL : Default Development. can be staging, production as well.
  • createHost
    Create a host in that property. By default Akamai host.
    Arguments:
    • name : REQUIRED : name of the host.
    • host_type : OPTIONAL : type of host. ‘akamai’ or ‘sftp’. Default ‘akamai’
  • If the host type is sftp, additional info can be enter as kwargs:
    • username : REQUIRED : str : username of the sftp
    • encrypted_private_key : REQUIRED : str : private key for the sftp as string
    • server : REQUIRED : str : server for the sftp.
    • path : REQUIRED : str : path of the sftp
    • port : REQUIRED : int : port to use

Documentation : https://developer.adobelaunch.com/api/reference/1.0/hosts/create/

  • createLibrary
    Create a library with the name provided. Returns an instance of the Library class or the response from the API (object).
    Arguments:
    • name : REQUIRED : name of the library
    • return_class : OPTIONAL : Bool. will return a instance of the Library class if True.

The delete methods

The delete methods enable the possibility to delete some of the elements that a property has.
I didn’t cover the whole possibilities because I don’t think that it is an usual behavior to delete the Library in all of the properties, as an example, but feel free to add this possibility if you feel like it. This is open source after all.

Overall the different delete methods that are available, are the following:

  • deleteExtension
    Delete the extension that you want.
    Arguments:
    • extension_id : REQUIRED : Rule ID that needs to be deleted
  • deleteRule
    Delete the rule that you want.
    Arguments:
    • rule_id : REQUIRED : Rule ID that needs to be deleted
  • deleteDataElement
    Delete a data element.
    Arguments:
    • dataElement_id : REQUIRED : Data Element ID that needs to be deleted
  • deleteRuleComponent
    Delete the rule component that you have selected.
    Arguments:
    • rc_id : REQUIRED : Rule Component ID that needs to be deleted
  • deleteEnvironments
    Delete the environment based on the id.
    Arguments:
    • env_id : REQUIRED : Environment ID that needs to be deleted

The update methods

The update method should be something that you would really like to use. However the update method is not available for all of the elements of a properties.
Or at least they are not referenced in the documentation. I didn’t test it yet.
Below are the one that I already wrote, and the elements required. Feel free to contribute based on that template.

  • updateRules
    Update the rule based on elements passed in attr_dict.
    Arguments:
    • rule_id : REQUIRED : Rule ID
    • attr_dict : REQUIRED : dictionary that will be passed to Launch for update.

I will add some comments for the first one, because the following ones are supposed to take same type of element. The attr_dict is the whole attributes dictionary with the new value you want to pass.
As far as it is written in the documentation, this is the only thing that you can edit.
For some action (data element taking another extension as reference, you would need to create a new data element).

  • updateRuleComponents
    Update the ruleComponents based on the information provided.
    Arguments:
    • rc_id : REQUIRED : Rule Component ID
    • attr_dict : REQUIRED : dictionary that will be passed to Launch for update
  • updateDataElements
    Update the data element information based on the information provided.
    Arguments:
    • dataElement_id : REQUIRED : Data Element ID
    • attr_dict : REQUIRED : dictionary that will be passed to Launch for update
  • updateEnvironment
    Update an environment. Note :only support name change.
    Arguments:
    • name : REQUIRED : name of your environment
    • env_id : REQUIRED : The environement id.
  • updateExtensions
    update the extension with the information provided in the argument.
    Arguments:
    • extension_id : REQUIRED : the extension id
    • attr_dict : REQUIRED : dictionary that will be passed to Launch for update

Overall, for the update methods, I would recommend you to use the extractAttributes or duplicateAttributes mehods in the core components methods. These should help you to manage your properties.

Code Examples

Here are some code example for your property management :

I hope this post helps you to better understand the pylaunch Property class 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 *