Exemplo n.º 1
0
        // This method will be called for each input received from the pipeline to this cmdlet; if no input is received, this method is not called
        protected override void ProcessRecord()
        {
            UplinkSettings     set  = new UplinkSettings();
            SetBandwidthLimits band = new SetBandwidthLimits();
            Cellular           cell = new Cellular();
            Wan1 wan1 = new Wan1();
            Wan2 wan2 = new Wan2();

            wan1.limitDown      = wan1DownLimit;
            wan1.limitUp        = wan1UpLimit;
            wan2.limitDown      = wan2DownLimit;
            wan2.limitUp        = wan2UpLimit;
            cell.limitUp        = CellularUpLimit;
            cell.limitDown      = CellularDownLimit;
            band.wan1           = wan1;
            band.wan2           = wan2;
            band.cellular       = cell;
            set.bandwidthLimits = band;

            WriteVerbose("Entering Get Orgs call");
            var list = ProcessRecordAsync(Token, netid, set);

            UplinkSettings result = JsonSerializer.Deserialize <UplinkSettings>(list);

            WriteObject(result, true);

            WriteVerbose("Exiting foreach");
        }
Exemplo n.º 2
0
        private static async Task <string> UpdateUplinks(string Token, string netid, UplinkSettings set)
        {
            using (HttpClient client = new HttpClient())
            {
                string jsonString;
                string uri;
                uri        = $"https://dashboard.meraki.com/api/v0/networks/{netid}/uplinkSettings";
                jsonString = JsonSerializer.Serialize <UplinkSettings>(set);

                var content = new StringContent(jsonString);
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
                client.DefaultRequestHeaders.Add("X-Cisco-Meraki-API-Key", Token);

                var response = await client.PutAsync(uri, content);

                var contents = await response.Content.ReadAsStringAsync();

                return(contents);
            }
        }
Exemplo n.º 3
0
        private static string ProcessRecordAsync(string Token, string netid, UplinkSettings set)
        {
            var task = UpdateUplinks(Token, netid, set);

            task.Wait();
            var result = task.Result;

            return(result);
        }