yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/azure/app_gateways.go (about) 1 // Copyright 2019 Yunion 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package azure 16 17 import ( 18 "net/url" 19 "strings" 20 21 "yunion.io/x/pkg/errors" 22 23 "yunion.io/x/cloudmux/pkg/multicloud" 24 ) 25 26 type SGatewayipconfiguration struct { 27 Name string `json:"name"` 28 ID string `json:"id"` 29 Etag string `json:"etag"` 30 Properties struct { 31 Provisioningstate string `json:"provisioningState"` 32 Subnet struct { 33 ID string `json:"id"` 34 } `json:"subnet"` 35 } `json:"properties"` 36 Type string `json:"type"` 37 } 38 39 type SFrontendipconfiguration struct { 40 Name string `json:"name"` 41 ID string `json:"id"` 42 Etag string `json:"etag"` 43 Type string `json:"type"` 44 Properties struct { 45 Provisioningstate string `json:"provisioningState"` 46 Privateipallocationmethod string `json:"privateIPAllocationMethod"` 47 PublicIPAddress struct { 48 ID string 49 } 50 PrivateIPAddress string 51 Subnet struct { 52 ID string `json:"id"` 53 } `json:"subnet"` 54 Httplisteners []struct { 55 ID string `json:"id"` 56 } `json:"httpListeners"` 57 } `json:"properties"` 58 } 59 60 type SFrontendport struct { 61 Name string `json:"name"` 62 ID string `json:"id"` 63 Etag string `json:"etag"` 64 Properties struct { 65 Provisioningstate string `json:"provisioningState"` 66 Port int `json:"port"` 67 Httplisteners []struct { 68 ID string `json:"id"` 69 } `json:"httpListeners"` 70 } `json:"properties"` 71 Type string `json:"type"` 72 } 73 74 type SBackendaddresspool struct { 75 Name string `json:"name"` 76 ID string `json:"id"` 77 Etag string `json:"etag"` 78 Properties struct { 79 Provisioningstate string `json:"provisioningState"` 80 Backendaddresses []interface{} `json:"backendAddresses"` 81 Requestroutingrules []struct { 82 ID string `json:"id"` 83 } `json:"requestRoutingRules"` 84 } `json:"properties"` 85 Type string `json:"type"` 86 } 87 88 type SBackendhttpsettingscollection struct { 89 Name string `json:"name"` 90 ID string `json:"id"` 91 Etag string `json:"etag"` 92 Properties struct { 93 Provisioningstate string `json:"provisioningState"` 94 Port int `json:"port"` 95 Protocol string `json:"protocol"` 96 Cookiebasedaffinity string `json:"cookieBasedAffinity"` 97 Pickhostnamefrombackendaddress bool `json:"pickHostNameFromBackendAddress"` 98 Requesttimeout int `json:"requestTimeout"` 99 Requestroutingrules []struct { 100 ID string `json:"id"` 101 } `json:"requestRoutingRules"` 102 } `json:"properties"` 103 Type string `json:"type"` 104 } 105 106 type SHttplistener struct { 107 Name string `json:"name"` 108 ID string `json:"id"` 109 Etag string `json:"etag"` 110 Properties struct { 111 Provisioningstate string `json:"provisioningState"` 112 Frontendipconfiguration struct { 113 ID string `json:"id"` 114 } `json:"frontendIPConfiguration"` 115 Frontendport struct { 116 ID string `json:"id"` 117 } `json:"frontendPort"` 118 Protocol string `json:"protocol"` 119 Requireservernameindication bool `json:"requireServerNameIndication"` 120 Requestroutingrules []struct { 121 ID string `json:"id"` 122 } `json:"requestRoutingRules"` 123 } `json:"properties"` 124 Type string `json:"type"` 125 } 126 127 type SRequestroutingrule struct { 128 Name string `json:"name"` 129 ID string `json:"id"` 130 Etag string `json:"etag"` 131 Properties struct { 132 Provisioningstate string `json:"provisioningState"` 133 Ruletype string `json:"ruleType"` 134 Httplistener struct { 135 ID string `json:"id"` 136 } `json:"httpListener"` 137 Backendaddresspool struct { 138 ID string `json:"id"` 139 } `json:"backendAddressPool"` 140 Backendhttpsettings struct { 141 ID string `json:"id"` 142 } `json:"backendHttpSettings"` 143 } `json:"properties"` 144 Type string `json:"type"` 145 } 146 147 type SApplicationGatewayProperties struct { 148 Provisioningstate string `json:"provisioningState"` 149 Resourceguid string `json:"resourceGuid"` 150 Sku struct { 151 Name string `json:"name"` 152 Tier string `json:"tier"` 153 Capacity string `json:"capacity"` 154 } `json:"sku"` 155 Operationalstate string `json:"operationalState"` 156 Gatewayipconfigurations []SGatewayipconfiguration `json:"gatewayIPConfigurations"` 157 Sslcertificates []interface{} `json:"sslCertificates"` 158 Authenticationcertificates []interface{} `json:"authenticationCertificates"` 159 Frontendipconfigurations []SFrontendipconfiguration `json:"frontendIPConfigurations"` 160 Frontendports []SFrontendport `json:"frontendPorts"` 161 Backendaddresspools []SBackendaddresspool `json:"backendAddressPools"` 162 Backendhttpsettingscollection []SBackendhttpsettingscollection `json:"backendHttpSettingsCollection"` 163 Httplisteners []SHttplistener `json:"httpListeners"` 164 Urlpathmaps []interface{} `json:"urlPathMaps"` 165 Requestroutingrules []SRequestroutingrule `json:"requestRoutingRules"` 166 Probes []interface{} `json:"probes"` 167 Redirectconfigurations []interface{} `json:"redirectConfigurations"` 168 Webapplicationfirewallconfiguration struct { 169 Enabled bool `json:"enabled"` 170 Firewallmode string `json:"firewallMode"` 171 Rulesettype string `json:"ruleSetType"` 172 Rulesetversion string `json:"ruleSetVersion"` 173 Disabledrulegroups []interface{} `json:"disabledRuleGroups"` 174 Requestbodycheck bool `json:"requestBodyCheck"` 175 } `json:"webApplicationFirewallConfiguration"` 176 Enablehttp2 bool `json:"enableHttp2"` 177 } 178 179 type SApplicationGateway struct { 180 region *SRegion 181 multicloud.SResourceBase 182 AzureTags 183 184 Name string `json:"name"` 185 Id string `json:"id"` 186 Etag string `json:"etag"` 187 Type string `json:"type"` 188 Location string `json:"location"` 189 Properties SApplicationGatewayProperties `json:"properties"` 190 } 191 192 func (self *SApplicationGateway) GetName() string { 193 return self.Name 194 } 195 196 func (self *SApplicationGateway) GetId() string { 197 return self.Id 198 } 199 200 func (self *SApplicationGateway) GetGlobalId() string { 201 return strings.ToLower(self.Id) 202 } 203 204 func (self *SRegion) ListAppGateways() ([]SApplicationGateway, error) { 205 apps := []SApplicationGateway{} 206 err := self.list("Microsoft.Network/applicationGateways", url.Values{}, &apps) 207 if err != nil { 208 return nil, errors.Wrapf(err, "list") 209 } 210 return apps, nil 211 } 212 213 func (self *SRegion) GetApplicationGateway(id string) (*SApplicationGateway, error) { 214 ret := &SApplicationGateway{region: self} 215 return ret, self.get(id, url.Values{}, ret) 216 }