Esempio n. 1
0
 def __init__(self, url: str, token: str, throws: bool = True, ssl_verify: bool = True):
     """Creates instance of the 3scale client
     Args:
         url: 3scale instance url
         token: Access token
         throws: Whether it should throw an error
         ssl_verify: Whether to verify ssl
     """
     self._rest = RestApiClient(url=url, token=token, throws=throws, ssl_verify=ssl_verify)
     self._services = resources.Services(self, instance_klass=resources.Service)
     self._accounts = resources.Accounts(self, instance_klass=resources.Account)
     self._provider_accounts = \
         resources.ProviderAccounts(self, instance_klass=resources.ProviderAccount)
     self._provider_account_users = \
         resources.ProviderAccountUsers(self, instance_klass=resources.ProviderAccountUser)
     self._methods = resources.Methods(self, instance_klass=resources.Method)
     self._metrics = resources.Metrics(self, instance_klass=resources.Metric)
     self._analytics = resources.Analytics(self)
     self._tenants = resources.Tenants(self, instance_klass=resources.Tenant)
     self._providers = resources.Providers(self, instance_klass=resources.Provider)
     self._access_tokens = \
         resources.AccessTokens(self, instance_klass=resources.AccessToken)
     self._active_docs = resources.ActiveDocs(self, instance_klass=resources.ActiveDoc)
     self._account_plans = resources.AccountPlans(self, instance_klass=resources.AccountPlan)
     self._settings = resources.SettingsClient(self)
     self._admin_portal_auth_provider = resources.AdminPortalAuthenticationProvider(self)
     self._dev_portal_auth_provider = resources.DevPortalAuthenticationProvider(self)
     self._policy_registry = resources.PoliciesRegistry(self,
                                                        instance_klass=resources.PolicyRegistry)
     self._backends = resources.Backends(self, instance_klass=resources.Backend)
     self._webhooks = resources.Webhooks(self)
     self._invoices = resources.Invoices(self, instance_klass=resources.Invoice)
Esempio n. 2
0
    def __init__(self,
                 url: str,
                 token: str,
                 throws: bool = True,
                 ssl_verify: bool = True,
                 wait: bool = False):
        """Creates instance of the 3scale client
        Args:
            url: 3scale instance url
            token: Access token
            throws: Whether it should throw an error
            ssl_verify: Whether to verify ssl
            wait: Whether to do extra checks of 3scale availability
        """
        self._rest = RestApiClient(url=url,
                                   token=token,
                                   throws=throws,
                                   ssl_verify=ssl_verify)
        self._services = resources.Services(self,
                                            instance_klass=resources.Service)
        self._accounts = resources.Accounts(self,
                                            instance_klass=resources.Account)
        self._provider_accounts = \
            resources.ProviderAccounts(self, instance_klass=resources.ProviderAccount)
        self._provider_account_users = \
            resources.ProviderAccountUsers(self, instance_klass=resources.ProviderAccountUser)
        self._methods = resources.Methods(self,
                                          instance_klass=resources.Method)
        self._metrics = resources.Metrics(self,
                                          instance_klass=resources.Metric)
        self._analytics = resources.Analytics(self)
        self._tenants = resources.Tenants(self,
                                          instance_klass=resources.Tenant)
        self._providers = resources.Providers(
            self, instance_klass=resources.Provider)
        self._access_tokens = \
            resources.AccessTokens(self, instance_klass=resources.AccessToken)
        self._active_docs = resources.ActiveDocs(
            self, instance_klass=resources.ActiveDoc)
        self._account_plans = resources.AccountPlans(
            self, instance_klass=resources.AccountPlan)
        self._settings = resources.SettingsClient(self)
        self._admin_portal_auth_providers = resources.AdminPortalAuthProviders(
            self, instance_klass=resources.AdminPortalAuthProvider)
        self._dev_portal_auth_providers = resources.DevPortalAuthProviders(
            self, instance_klass=resources.DevPortalAuthProvider)
        self._policy_registry = resources.PoliciesRegistry(
            self, instance_klass=resources.PolicyRegistry)
        self._backends = resources.Backends(self,
                                            instance_klass=resources.Backend)
        self._webhooks = resources.Webhooks(self)
        self._invoices = resources.Invoices(self,
                                            instance_klass=resources.Invoice)
        self._fields_definitions =\
            resources.FieldsDefinitions(self, instance_klass=resources.FieldsDefinition)

        if wait:
            self.wait_for_tenant()
            # TODO: all the implemented checks aren't enough yet
            # 3scale can still return 404/409 error, therefore slight artificial sleep
            # here to mitigate the problem. This requires proper fix in checks
            time.sleep(16)