Ejemplo n.º 1
0
        public void ManageCDoms(int requestTimeout)
        {
            var api = new MaxCDN.Api("ALIAS", "KEY", "SECRET", requestTimeout);

            Console.Write("1. List\n2. Create\n3. Edit\n4. Delete\n\n");
            int choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            case 1:
                Console.Write("Zone Type? (pull/push/vod)\n");
                string list = Console.ReadLine();
                Console.Write("Zone ID: \n");
                int czid = Convert.ToInt32(Console.ReadLine());
                Console.Write(api.Get("/zones/pull/" + czid + "/customdomains.json"));
                break;

            case 2:
                Console.Write("Zone Type? (pull/push/vod)\n");
                string create = Console.ReadLine();
                Console.Write("Custom Domain: \n");
                string cdname = Console.ReadLine();
                Console.Write("Zone ID: \n");
                string cdzid = Console.ReadLine();
                string param = "";
                param = "custom_domain=" + cdname;

                Console.Write(api.Post("/zones/pull/" + cdzid + "/customdomains.json", param));
                break;

            case 3:
                Console.Write("Zone Type: (pull/push/vod)\n");
                string edit = Console.ReadLine();
                Console.Write("Zone ID: \n");
                int zoneID = Convert.ToInt32(Console.ReadLine());
                Console.Write(api.Get("/zones/" + edit + "/" + zoneID + "/customdomains.json") + "\n");
                Console.Write("Custom Domain ID: \n");
                int cid = Convert.ToInt32(Console.ReadLine());
                Console.Write("New Value: \n");
                string val = Console.ReadLine();

                api.Put("/zones/" + edit + "/" + zoneID + "/customdomains.json/" + cid, "custom_domain=" + val);

                break;

            case 4:
                Console.Write("Zone Type: (pull/push/vod)\n");
                string delete = Console.ReadLine();
                Console.Write("Zone ID: \n");
                int zID = Convert.ToInt32(Console.ReadLine());
                Console.Write(api.Get("/zones/" + delete + "/" + zID + "/customdomains.json") + "\n");
                Console.Write("Custom Domain ID: \n");
                int ciddel = Convert.ToInt32(Console.ReadLine());
                api.Delete("/zones/pull/" + zID + "/customdomains.json/" + ciddel);
                break;
            }
        }
Ejemplo n.º 2
0
        public void ManageZones(int requestTimeout)
        {
            var api = new MaxCDN.Api("ALIAS", "KEY", "SECRET", requestTimeout);

            Console.Write("1. List\n2. Create\n3. Edit\n4. Delete\n\n");
            int choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            case 1:
                Console.Write("Zone Type? (pull/push/vod)\n");
                string list = Console.ReadLine();
                Console.Write(api.Get("/zones/" + list + ".json"));
                break;

            case 2:
                Console.Write("Zone Type? (pull/push/vod)\n");
                string create = Console.ReadLine();
                Console.Write("Zone Name: \n");
                string ZoneName = Console.ReadLine();
                string param    = "";
                if (create == "pull")
                {
                    Console.Write("Origin URL (starting with http://): \n");
                    string url = Console.ReadLine();
                    param = "url=" + url + "&name=" + ZoneName;
                }
                if (create != "pull")
                {
                    Console.Write("Password: \n");
                    string password = Console.ReadLine();
                    param = "password="******"&name=" + ZoneName;
                }

                api.Post("/zones/" + create + ".json", param);
                break;

            case 3:
                Console.Write("Zone Type: (pull/push/vod)");
                string edit = Console.ReadLine();
                if (edit == "pull")
                {
                    Console.Write("Zone ID: \n");
                    int zoneID = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Choose property: compress, url, use_stale,... full list: https://docs.maxcdn.com\n");
                    string prop = Console.ReadLine();
                    Console.Write("New Value: \n");
                    string val = Console.ReadLine();
                    api.Put("/zones/" + edit + ".json/" + zoneID, prop + "=" + val);
                }
                break;

            case 4:
                Console.Write("Zone Type: (pull/push/vod)");
                string delete = Console.ReadLine();
                Console.Write("Zone ID: \n");
                int zID = Convert.ToInt32(Console.ReadLine());
                api.Delete("/zones/" + delete + ".json/" + zID);
                break;
            }
        }