Exemple #1
0
        private static async Task <string> AddVlans(string Token, string netid, CreateMerakiVlan vlan)
        {
            using (HttpClient client = new HttpClient())
            {
                string jsonString;
                string uri;
                uri        = $"https://dashboard.meraki.com/api/v0/networks/{netid}/vlans";
                jsonString = JsonSerializer.Serialize <CreateMerakiVlan>(vlan);

                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.PostAsync(uri, content);

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

                return(contents);
            }
        }
Exemple #2
0
        private static string ProcessRecordAsync(string Token, string netid, CreateMerakiVlan vlan)
        {
            var task = AddVlans(Token, netid, vlan);

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

            return(result);
        }
Exemple #3
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()
        {
            CreateMerakiVlan vlan = new CreateMerakiVlan();

            vlan.name        = name;
            vlan.id          = vlanid;
            vlan.applianceIp = applianceIp;
            vlan.subnet      = subnet;
            WriteVerbose("Entering Get Orgs call");
            var list = ProcessRecordAsync(Token, netid, vlan);
            CreateMerakiVlan result = JsonSerializer.Deserialize <CreateMerakiVlan>(list);

            WriteObject(result, true);


            WriteVerbose("Exiting foreach");
        }