...
1
2
3
4 package virtualnetwork
5
6
7
8
9 import (
10 "encoding/xml"
11
12 "github.com/Azure/azure-sdk-for-go/services/classic/management"
13 )
14
15 const (
16 azureNetworkConfigurationURL = "services/networking/media"
17 )
18
19
20 func NewClient(client management.Client) VirtualNetworkClient {
21 return VirtualNetworkClient{client: client}
22 }
23
24
25
26
27
28 func (c VirtualNetworkClient) GetVirtualNetworkConfiguration() (NetworkConfiguration, error) {
29 networkConfiguration := c.NewNetworkConfiguration()
30 response, err := c.client.SendAzureGetRequest(azureNetworkConfigurationURL)
31 if err != nil {
32 return networkConfiguration, err
33 }
34
35 err = xml.Unmarshal(response, &networkConfiguration)
36 return networkConfiguration, err
37
38 }
39
40
41
42
43
44 func (c VirtualNetworkClient) SetVirtualNetworkConfiguration(networkConfiguration NetworkConfiguration) (management.OperationID, error) {
45 networkConfiguration.setXMLNamespaces()
46 networkConfigurationBytes, err := xml.Marshal(networkConfiguration)
47 if err != nil {
48 return "", err
49 }
50
51 return c.client.SendAzurePutRequest(azureNetworkConfigurationURL, "text/plain", networkConfigurationBytes)
52 }
53
View as plain text