예제 #1
0
def get_credentials(workspace, key):
    credentials = ""

    json_creds = server._get(SERVER_URL +
                             "/_api/v2/ws/%s/credential" % workspace)

    if len(json_creds["rows"]) > 0:

        for c in json_creds["rows"]:
            credentials += c["value"][key] + "\n"
        return credentials

    else:
        sys.exit("No credentials were found on faraday")
예제 #2
0
def show_table_services(workspace):

    services = []
    table = ""

    j_parsed = server._get(
        SERVER_URL + "/_api/v2/ws/%s/services/count?group_by=name" % workspace)

    if len(j_parsed["groups"]) > 0:

        table += "Number\tService\tCount\n"
        table += "------\t-------\t------\n"

        for l in j_parsed["groups"]:
            if l["name"] in SUPPORTED_SERVICES:
                services.append(l["name"])
                table += "[" + str(services.index(l["name"])) + "]\t"
                table += l["name"] + "\t" + str(l["count"]) + "\n"
        return table, services

    else:
        sys.exit("No services availables")
예제 #3
0
 def test_get(self):
     url = "http://get_url"
     responses.add(responses.GET, url, body='{"some": "object"}')
     expected_json = server._get(url)
     self.assertEqual(expected_json, {"some": "object"})
예제 #4
0
def total_credentials(workspace):
    json_creds = server._get(SERVER_URL +
                             "/_api/v2/ws/%s/credential" % workspace)

    return len(json_creds["rows"])