Last active
December 18, 2019 12:17
-
-
Save zoharbabin/c843a8c86122892d78ebfd5cf3b1182e to your computer and use it in GitHub Desktop.
Using the Kaltura API to create Sub-Accounts (See: https://developer.kaltura.com/console/service/partner/action/register)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'kaltura' | |
include Kaltura | |
config = KalturaConfiguration.new() | |
config.service_url = 'https://www.kaltura.com' | |
client = KalturaClient.new(config); | |
parent_partner_id = # Your Kaltura Parent MultiAccount Partner ID (Kaltura Account ID) | |
login_id = #Your Kaltura Parent MultiAccount Admin Login Email | |
password = #Your Kaltura Parent MultiAccount Admin Login Password | |
partner_name = #Your own-system Account Name (string that will tell you which of your own customers this subaccount belongs to) | |
partner_email = #Your own-system customer login email (if your customers are to be allowed Admin access, otherwise this could something like AccountID@edcast.com) | |
template_partner_id = #Your Kaltura Template Account (This will be used to copy any template content or settings that should be uniformly applied to all of your sub-accounts). | |
expiry = 86400 | |
privileges = "*" #This is important permission to be able to create sub-accounts | |
client.ks = client.user_service.login_by_login_id(login_id, password, parent_partner_id, expiry, privileges) | |
partner = KalturaPartner.new() | |
partner.admin_name = partner_name | |
partner.name = partner_name | |
partner.type = KalturaPartnerType::ADMIN_CONSOLE | |
partner.partner_parent_id = parent_partner_id | |
partner.admin_email = partner_email | |
partner.reference_id = '' # Use this to store your own system Account ID (the id of the customer account in your own system), this is useful for reporting and search later | |
partner.website='' # Your customer domain name / website | |
partner.description=' ' #Cannot be null, but can be a space, use this to store any needed description or notes about this subaccount | |
cms_password = nil | |
silent = false | |
result = client.partner_service.register(partner, cms_password, template_partner_id, silent) | |
puts 'New partner ID is ' + result.id.to_s |
To manage (change the status) of a sub-account, use the update_status action API:
partner_id = # The ID of the sub-account to modify
status = # where status is one of the above: KalturaPartnerStatus::DELETED, KalturaPartnerStatus::ACTIVE, KalturaPartnerStatus::BLOCKED, KalturaPartnerStatus::FULL_BLOCK
client.var_console_service.update_status(partner_id, status)
Note, this API action is on the var_console service, it does not belong to the Partner service. https://developer.kaltura.com/console/service/varConsole/action/updateStatus
IMPORTANT NOTE: Please use this with caution as this will allow you to delete your PARENT partner as well and once done, you will need to contact Kaltura Support in order to re-activate it.
The statuses in KalturaPartnerStatus:
- ACTIVE - This account is fully active and accessible.
- BLOCKED – The account is not accessible, and will not be able to access the API using its API secrets. This account can be unblocked laat future time and its content will not be deleted (to be able to block accounts temporary and later fully restore them, use this status).
- DELETED – Partner in delete state will not return in partner list, meaning there will be no access to it from API, its content is going to be cleaned in a near-future cleanup cycle. Account could be unblocked, but content will not be available.
- FULL_BLOCKED – This account is blocked indefinitely, its content will be cleaned in the near-future cleanup cycle. Account with status will not be recoverable. Only use when you are certain this account will no longer be needed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To list all sub-accounts, use the partner.list API: