Package: ethel
EthelEthel is a tool that allows you to manipulate with accounts in Stage, QA or any other environment, buy Subscriptions, activate them and do other chores.InstalationpipinstallethelUsagePrerequisitesBefore you can use Ethel, you have to set up your environment accordingly:# Required:EBS_CERT_PUBLIC=<PATH_TO_EBS_SSL_CLIENT_CERTIFICATE>EBS_CERT_KEY=<PATH_TO_EBS_SSL_CLIENT_CERTIFICATE_KEY># Optional:CANDLEPIN_USERNAME=<CANDLEPIN_SUPERUSER_USERNAME># Defaults to "candlepin_admin"CANDLEPIN_PASSWORD=<CANDLEPIN_SUPERUSER_PASSWORD># Defaults to "candlepin_admin"Basic usageThe most basic usecase is to simply create an account and subscribe it to a product.>>>fromethelimportEthel>>>ethel=Ethel.stage()>>>account=ethel.create_account('some_fancy_username','not_so_secret_password')>>>account.subscribe('product_sku')Ethel provides access to Stage and QA environments viaEthel.stage()andEthel.qa()class methods.Advanced usageEthel, by default, processes everything for you when the account is being created. Also, if account with the same username already exists, Ethel verifies your credentials and returns you the already existant account entry.When account is being created, Ethel ensures that it's Candlepins owners are created (forces Candlepin refresh) and accepts all required Terms and Conditions. To disable this behavior, you can passcreate_owners=Falseand/oraccept_terms=Falsewhen creating account and do it yourself later:>>>account=ethel.create_account(..."some_fancy_username",..."not_so_secret_password",...first_name="Gretchen",...last_name="SomeOldSurname",...email="grandmas.dont.have@emails.com",...create_owners=False,...accept_terms=False,...)>>>account.start_refresh()>>>account.get_refresh_status()'RUNNING'>>>account.get_refresh_status()'FINISHED'>>>account.accept_all_terms(optional=True)# Accepts also the optional Terms and ConditionsYou can also specify more details about your desired subscription when asking Ethel to subscribe it you your account:>>>account.subscribe(...'product_sku',...quantity=42,...start_date='yesterday',# accepts 'yesterday', 'today', 'tomorrow', ISO date 'YYYY-MM-DD' or datetime.date...duration=365# accepts integer that means 'days' or datetime.timedelta...)Errors and ExceptionsIf an exception is returned to Ethel from either Candlepin or the EBS rest API services, they are unified and interfaced as anEthelError. Depending on the exact API that raised the exception, the level of detail varies. Following properties are stored:message- Should contain the reason why the exception occurred.message_type- Class of the exception reason description (different toexception_type).exception_type- Type of exception (class name).status_code- HTTP status code (EBS likes to return HTTP_500 for any reason).source- API that caused the exception.uuid- Exception's tracking code for Candlepin API.raw_error-HTTPErrorobject providing access toPreparedRequestandResponsedirectly.Ethel does not handlerequests.ConnectionErrorandrequests.Timeout.For convenience a shorthandEthelConnectionErroris provided.Ethel doesn't retry any request, it's up to user to handle this behavior.>>>account=ethel.create_account('USERNAME','WRONG_PASSWORD')EthelError:From:Candlepin(api_base_url=<CANDLEPIN_URL_FOR_THIS_ENV>).Reason:Invalidusercredentials.Statuscode:401.Call(method=GET,url=<CANDLEPIN_URL_FOR_THIS_ENV>)/users/<USERNAME>/owners).>>>try:...account=ethel.create_account('<USERNAME>','<WRONG_PASSWORD>')...exceptEthelErrorase:...logging.error("Status Code%d, Message:%s, Tracking code%s"%(e.status_code,e.message,e.uuid))ERROR:root:StatusCode401,Message:Invalidusercredentials,Trackingcodee7275480-2c59-42fa-a6db-b8df6a9dc323Additional propertiesEthel stores few important properties for each of your accounts that might be usefull to you:Organization IDCandlepin Owner IDList of all Subscription orders done in this sessionList of all Activation orders done in this session>>>account.org_id123456789>>>account.owner_id987654321>>>account.orders[...]>>>account.activations[...]View AccountAnd since Ethel allows you to have a Black Friday for subscriptions everyday, you may want to look up all the things you've bought:>>>account.list_pools()# You can pass future=True argument to list also pools valid in future[{'pool_id':'<USE_THIS_TO_SUBSCRIBE>','sku_id':'<PRODUCT_SKU_ID>','product_name':'Fancy Product Name','start_date':'2020-02-07T05:00:00+0000','end_date':'2021-02-07T04:59:59+0000','muiltiplier':None,'quantity':'unlimited','instance_multiplier':None},{'pool_id':'<ALSO_USE_THIS_TO_SUBSCRIBE>','sku_id':'<ANOTHER_PRODUCT_SKU_ID>','product_name':'Fancy Product Name','start_date':'2020-02-06T05:00:00+0000','end_date':'2021-02-06T04:59:59+0000','muiltiplier':None,'quantity':1,'instance_multiplier':16},...]Developer setupAfter cloning this repo, setup the local environment viaPoetry:poetryinstallPrepared taskspoetry run task lint- runsMypyandPylintpoetry run task test- runsPytesttest suite