Exemplo n.º 1
0
    def init(self, tenantsurl="https://api.tacc.utexas.edu/tenants"):
        """ Initilize a session

        Initialize a session by setting parameters refering to the tenant you
        wish to interact with.
        """
        # The following sectionsets tenant ID (tenant_id) and tenant url
        # (api_server).
        # Neither tenant ID nor tenant url are set.
        if self.tenant_id is None and self.api_server is None:
            tenants = self.list_tenants(tenantsurl=tenantsurl)
            value = input(
                "\nPlease specify the ID for the tenant you wish to interact with: "
            )
            self.tenant_id = tenants[value]["id"]
            tenant_url = tenants[value]["url"]
            if tenant_url[-1] == '/':
                tenant_url = tenant_url[:-1]
            self.api_server = tenant_url
        # Tenant ID was not set.
        elif self.tenant_id is None and self.api_server is not None:
            tenants = tenant_list(tenantsurl=tenantsurl)

            for _, tenant in tenants.items():
                if self.api_server in tenant["url"]:
                    self.tenant_id = tenant["id"]
        # Tenant url was not set.
        elif self.api_server is None and self.tenant_id is not None:
            tenants = tenant_list(tenantsurl=tenantsurl)

            tenant_url = tenants[self.tenant_id]["url"]
            if tenant_url[-1] == '/':
                tenant_url = tenant_url[:-1]
            self.api_server = tenant_url
Exemplo n.º 2
0
    def init(self, tenantsurl="https://api.tacc.utexas.edu/tenants"):
        """ Initilize a session

        Initialize a session by setting parameters refering to the tenant you
        wish to interact with.
        """
        # The following sectionsets tenant ID (tenant_id) and tenant url
        # (api_server).
        # Neither tenant ID nor tenant url are set.
        if self.tenant_id is None and self.api_server is None:
            tenants = self.list_tenants(tenantsurl=tenantsurl)
            value = input("\nPlease specify the ID for the tenant you wish to interact with: ")
            self.tenant_id  = tenants[value]["id"]
            tenant_url = tenants[value]["url"]
            if tenant_url[-1] == '/':
                tenant_url = tenant_url[:-1]
            self.api_server = tenant_url
        # Tenant ID was not set.
        elif self.tenant_id is None and self.api_server is not None:
            tenants = tenant_list(tenantsurl=tenantsurl)

            for _, tenant in tenants.items():
                if self.api_server in tenant["url"]:
                    self.tenant_id = tenant["id"]
        # Tenant url was not set.
        elif self.api_server is None and self.tenant_id is not None:
            tenants = tenant_list(tenantsurl=tenantsurl)

            tenant_url = tenants[self.tenant_id]["url"]
            if tenant_url[-1] == '/':
                tenant_url = tenant_url[:-1]
            self.api_server = tenant_url
Exemplo n.º 3
0
    def list_tenants(self, tenantsurl="https://api.tacc.utexas.edu/tenants"):
        """ List Agave tenants

        PARAMETERS
        ----------
        tenantsurl: string (default: "https://api.tacc.utexas.edu/tenants")
            Endpoint with Agave tenant information. Another alternative is 
            https://api.tacc.utexas.edu/tenants.
        """
        tenants = tenant_list(tenantsurl)
        print("{0:<20} {1:<40} {2:<50}".format("ID", "NAME", "URL"))
        for _, tenant in tenants.items():
            print("{0:<20} {1:<40} {2:<50}".format(
                    tenant["id"], tenant["name"], tenant["url"]))

        return tenants
Exemplo n.º 4
0
    def list_tenants(self, tenantsurl="https://api.tacc.utexas.edu/tenants"):
        """ List Agave tenants

        PARAMETERS
        ----------
        tenantsurl: string (default: "https://api.tacc.utexas.edu/tenants")
            Endpoint with Agave tenant information. Another alternative is
            https://api.tacc.utexas.edu/tenants.
        """
        tenants = tenant_list(tenantsurl)
        print("{0:<20} {1:<40} {2:<50}".format("ID", "NAME", "URL"))
        for _, tenant in tenants.items():
            print("{0:<20} {1:<40} {2:<50}".format(
                    tenant["id"], tenant["name"], tenant["url"]))

        return tenants