2016-10-07 10:39:28 -04:00
//
2019-02-01 14:26:40 -05:00
// Copyright 2018, Sander van Harmelen
2016-10-07 10:39:28 -04:00
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package cloudstack
import (
"encoding/json"
"fmt"
"net/url"
"strconv"
"strings"
)
2019-02-01 14:26:40 -05:00
type AddNetworkServiceProviderParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * AddNetworkServiceProviderParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "destinationphysicalnetworkid" ] ; found {
u . Set ( "destinationphysicalnetworkid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "name" ] ; found {
u . Set ( "name" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "physicalnetworkid" ] ; found {
u . Set ( "physicalnetworkid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "servicelist" ] ; found {
vv := strings . Join ( v . ( [ ] string ) , "," )
u . Set ( "servicelist" , vv )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * AddNetworkServiceProviderParams ) SetDestinationphysicalnetworkid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "destinationphysicalnetworkid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * AddNetworkServiceProviderParams ) SetName ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "name" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * AddNetworkServiceProviderParams ) SetPhysicalnetworkid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "physicalnetworkid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * AddNetworkServiceProviderParams ) SetServicelist ( v [ ] string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "servicelist" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new AddNetworkServiceProviderParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewAddNetworkServiceProviderParams ( name string , physicalnetworkid string ) * AddNetworkServiceProviderParams {
p := & AddNetworkServiceProviderParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "name" ] = name
p . p [ "physicalnetworkid" ] = physicalnetworkid
2016-10-07 10:39:28 -04:00
return p
}
2019-02-01 14:26:40 -05:00
// Adds a network serviceProvider to a physical network
func ( s * NetworkService ) AddNetworkServiceProvider ( p * AddNetworkServiceProviderParams ) ( * AddNetworkServiceProviderResponse , error ) {
resp , err := s . cs . newRequest ( "addNetworkServiceProvider" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r AddNetworkServiceProviderResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type AddNetworkServiceProviderResponse struct {
Canenableindividualservice bool ` json:"canenableindividualservice" `
Destinationphysicalnetworkid string ` json:"destinationphysicalnetworkid" `
Id string ` json:"id" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Servicelist [ ] string ` json:"servicelist" `
State string ` json:"state" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type AddOpenDaylightControllerParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * AddOpenDaylightControllerParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "password" ] ; found {
u . Set ( "password" , v . ( string ) )
}
if v , found := p . p [ "physicalnetworkid" ] ; found {
u . Set ( "physicalnetworkid" , v . ( string ) )
}
if v , found := p . p [ "url" ] ; found {
u . Set ( "url" , v . ( string ) )
}
if v , found := p . p [ "username" ] ; found {
u . Set ( "username" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * AddOpenDaylightControllerParams ) SetPassword ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "password" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * AddOpenDaylightControllerParams ) SetPhysicalnetworkid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "physicalnetworkid" ] = v
return
}
func ( p * AddOpenDaylightControllerParams ) SetUrl ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "url" ] = v
return
}
func ( p * AddOpenDaylightControllerParams ) SetUsername ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "username" ] = v
return
}
// You should always use this function to get a new AddOpenDaylightControllerParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewAddOpenDaylightControllerParams ( password string , physicalnetworkid string , url string , username string ) * AddOpenDaylightControllerParams {
p := & AddOpenDaylightControllerParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "password" ] = password
p . p [ "physicalnetworkid" ] = physicalnetworkid
p . p [ "url" ] = url
p . p [ "username" ] = username
2016-10-07 10:39:28 -04:00
return p
}
2019-02-01 14:26:40 -05:00
// Adds an OpenDyalight controler
func ( s * NetworkService ) AddOpenDaylightController ( p * AddOpenDaylightControllerParams ) ( * AddOpenDaylightControllerResponse , error ) {
resp , err := s . cs . newRequest ( "addOpenDaylightController" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r AddOpenDaylightControllerResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type AddOpenDaylightControllerResponse struct {
Id string ` json:"id" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Url string ` json:"url" `
Username string ` json:"username" `
2016-10-07 10:39:28 -04:00
}
type CreateNetworkParams struct {
p map [ string ] interface { }
}
func ( p * CreateNetworkParams ) toURLValues ( ) url . Values {
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "account" ] ; found {
u . Set ( "account" , v . ( string ) )
}
if v , found := p . p [ "aclid" ] ; found {
u . Set ( "aclid" , v . ( string ) )
}
if v , found := p . p [ "acltype" ] ; found {
u . Set ( "acltype" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "bypassvlanoverlapcheck" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "bypassvlanoverlapcheck" , vv )
}
2016-10-07 10:39:28 -04:00
if v , found := p . p [ "displaynetwork" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "displaynetwork" , vv )
}
if v , found := p . p [ "displaytext" ] ; found {
u . Set ( "displaytext" , v . ( string ) )
}
if v , found := p . p [ "domainid" ] ; found {
u . Set ( "domainid" , v . ( string ) )
}
if v , found := p . p [ "endip" ] ; found {
u . Set ( "endip" , v . ( string ) )
}
if v , found := p . p [ "endipv6" ] ; found {
u . Set ( "endipv6" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "externalid" ] ; found {
u . Set ( "externalid" , v . ( string ) )
}
2016-10-07 10:39:28 -04:00
if v , found := p . p [ "gateway" ] ; found {
u . Set ( "gateway" , v . ( string ) )
}
if v , found := p . p [ "ip6cidr" ] ; found {
u . Set ( "ip6cidr" , v . ( string ) )
}
if v , found := p . p [ "ip6gateway" ] ; found {
u . Set ( "ip6gateway" , v . ( string ) )
}
if v , found := p . p [ "isolatedpvlan" ] ; found {
u . Set ( "isolatedpvlan" , v . ( string ) )
}
if v , found := p . p [ "name" ] ; found {
u . Set ( "name" , v . ( string ) )
}
if v , found := p . p [ "netmask" ] ; found {
u . Set ( "netmask" , v . ( string ) )
}
if v , found := p . p [ "networkdomain" ] ; found {
u . Set ( "networkdomain" , v . ( string ) )
}
if v , found := p . p [ "networkofferingid" ] ; found {
u . Set ( "networkofferingid" , v . ( string ) )
}
if v , found := p . p [ "physicalnetworkid" ] ; found {
u . Set ( "physicalnetworkid" , v . ( string ) )
}
if v , found := p . p [ "projectid" ] ; found {
u . Set ( "projectid" , v . ( string ) )
}
if v , found := p . p [ "startip" ] ; found {
u . Set ( "startip" , v . ( string ) )
}
if v , found := p . p [ "startipv6" ] ; found {
u . Set ( "startipv6" , v . ( string ) )
}
if v , found := p . p [ "subdomainaccess" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "subdomainaccess" , vv )
}
if v , found := p . p [ "vlan" ] ; found {
u . Set ( "vlan" , v . ( string ) )
}
if v , found := p . p [ "vpcid" ] ; found {
u . Set ( "vpcid" , v . ( string ) )
}
if v , found := p . p [ "zoneid" ] ; found {
u . Set ( "zoneid" , v . ( string ) )
}
return u
}
func ( p * CreateNetworkParams ) SetAccount ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "account" ] = v
return
}
func ( p * CreateNetworkParams ) SetAclid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "aclid" ] = v
return
}
func ( p * CreateNetworkParams ) SetAcltype ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "acltype" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateNetworkParams ) SetBypassvlanoverlapcheck ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "bypassvlanoverlapcheck" ] = v
return
}
2016-10-07 10:39:28 -04:00
func ( p * CreateNetworkParams ) SetDisplaynetwork ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "displaynetwork" ] = v
return
}
func ( p * CreateNetworkParams ) SetDisplaytext ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "displaytext" ] = v
return
}
func ( p * CreateNetworkParams ) SetDomainid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "domainid" ] = v
return
}
func ( p * CreateNetworkParams ) SetEndip ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "endip" ] = v
return
}
func ( p * CreateNetworkParams ) SetEndipv6 ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "endipv6" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateNetworkParams ) SetExternalid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "externalid" ] = v
return
}
2016-10-07 10:39:28 -04:00
func ( p * CreateNetworkParams ) SetGateway ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "gateway" ] = v
return
}
func ( p * CreateNetworkParams ) SetIp6cidr ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "ip6cidr" ] = v
return
}
func ( p * CreateNetworkParams ) SetIp6gateway ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "ip6gateway" ] = v
return
}
func ( p * CreateNetworkParams ) SetIsolatedpvlan ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "isolatedpvlan" ] = v
return
}
func ( p * CreateNetworkParams ) SetName ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "name" ] = v
return
}
func ( p * CreateNetworkParams ) SetNetmask ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "netmask" ] = v
return
}
func ( p * CreateNetworkParams ) SetNetworkdomain ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "networkdomain" ] = v
return
}
func ( p * CreateNetworkParams ) SetNetworkofferingid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "networkofferingid" ] = v
return
}
func ( p * CreateNetworkParams ) SetPhysicalnetworkid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "physicalnetworkid" ] = v
return
}
func ( p * CreateNetworkParams ) SetProjectid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "projectid" ] = v
return
}
func ( p * CreateNetworkParams ) SetStartip ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "startip" ] = v
return
}
func ( p * CreateNetworkParams ) SetStartipv6 ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "startipv6" ] = v
return
}
func ( p * CreateNetworkParams ) SetSubdomainaccess ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "subdomainaccess" ] = v
return
}
func ( p * CreateNetworkParams ) SetVlan ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "vlan" ] = v
return
}
func ( p * CreateNetworkParams ) SetVpcid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "vpcid" ] = v
return
}
func ( p * CreateNetworkParams ) SetZoneid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "zoneid" ] = v
return
}
// You should always use this function to get a new CreateNetworkParams instance,
// as then you are sure you have configured all required params
func ( s * NetworkService ) NewCreateNetworkParams ( displaytext string , name string , networkofferingid string , zoneid string ) * CreateNetworkParams {
p := & CreateNetworkParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "displaytext" ] = displaytext
p . p [ "name" ] = name
p . p [ "networkofferingid" ] = networkofferingid
p . p [ "zoneid" ] = zoneid
return p
}
// Creates a network
func ( s * NetworkService ) CreateNetwork ( p * CreateNetworkParams ) ( * CreateNetworkResponse , error ) {
resp , err := s . cs . newRequest ( "createNetwork" , p . toURLValues ( ) )
if err != nil {
return nil , err
}
if resp , err = getRawValue ( resp ) ; err != nil {
return nil , err
}
var r CreateNetworkResponse
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
type CreateNetworkResponse struct {
2019-02-01 14:26:40 -05:00
Account string ` json:"account" `
Aclid string ` json:"aclid" `
Acltype string ` json:"acltype" `
Broadcastdomaintype string ` json:"broadcastdomaintype" `
Broadcasturi string ` json:"broadcasturi" `
Canusefordeploy bool ` json:"canusefordeploy" `
Cidr string ` json:"cidr" `
Displaynetwork bool ` json:"displaynetwork" `
Displaytext string ` json:"displaytext" `
Dns1 string ` json:"dns1" `
Dns2 string ` json:"dns2" `
Domain string ` json:"domain" `
Domainid string ` json:"domainid" `
Externalid string ` json:"externalid" `
Gateway string ` json:"gateway" `
Id string ` json:"id" `
Ip6cidr string ` json:"ip6cidr" `
Ip6gateway string ` json:"ip6gateway" `
Isdefault bool ` json:"isdefault" `
Ispersistent bool ` json:"ispersistent" `
Issystem bool ` json:"issystem" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Netmask string ` json:"netmask" `
Networkcidr string ` json:"networkcidr" `
Networkdomain string ` json:"networkdomain" `
Networkofferingavailability string ` json:"networkofferingavailability" `
Networkofferingconservemode bool ` json:"networkofferingconservemode" `
Networkofferingdisplaytext string ` json:"networkofferingdisplaytext" `
Networkofferingid string ` json:"networkofferingid" `
Networkofferingname string ` json:"networkofferingname" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Redundantrouter bool ` json:"redundantrouter" `
Related string ` json:"related" `
Reservediprange string ` json:"reservediprange" `
Restartrequired bool ` json:"restartrequired" `
Service [ ] CreateNetworkResponseService ` json:"service" `
Specifyipranges bool ` json:"specifyipranges" `
State string ` json:"state" `
Strechedl2subnet bool ` json:"strechedl2subnet" `
Subdomainaccess bool ` json:"subdomainaccess" `
Tags [ ] Tags ` json:"tags" `
Traffictype string ` json:"traffictype" `
Type string ` json:"type" `
Vlan string ` json:"vlan" `
Vpcid string ` json:"vpcid" `
Zoneid string ` json:"zoneid" `
Zonename string ` json:"zonename" `
Zonesnetworkspans [ ] interface { } ` json:"zonesnetworkspans" `
}
type CreateNetworkResponseService struct {
Capability [ ] CreateNetworkResponseServiceCapability ` json:"capability" `
Name string ` json:"name" `
Provider [ ] CreateNetworkResponseServiceProvider ` json:"provider" `
}
type CreateNetworkResponseServiceProvider struct {
Canenableindividualservice bool ` json:"canenableindividualservice" `
Destinationphysicalnetworkid string ` json:"destinationphysicalnetworkid" `
Id string ` json:"id" `
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Servicelist [ ] string ` json:"servicelist" `
State string ` json:"state" `
}
type CreateNetworkResponseServiceCapability struct {
Canchooseservicecapability bool ` json:"canchooseservicecapability" `
Name string ` json:"name" `
Value string ` json:"value" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type CreatePhysicalNetworkParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * CreatePhysicalNetworkParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "broadcastdomainrange" ] ; found {
u . Set ( "broadcastdomainrange" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "domainid" ] ; found {
u . Set ( "domainid" , v . ( string ) )
}
if v , found := p . p [ "isolationmethods" ] ; found {
vv := strings . Join ( v . ( [ ] string ) , "," )
u . Set ( "isolationmethods" , vv )
}
if v , found := p . p [ "name" ] ; found {
u . Set ( "name" , v . ( string ) )
}
if v , found := p . p [ "networkspeed" ] ; found {
u . Set ( "networkspeed" , v . ( string ) )
}
if v , found := p . p [ "tags" ] ; found {
vv := strings . Join ( v . ( [ ] string ) , "," )
u . Set ( "tags" , vv )
}
if v , found := p . p [ "vlan" ] ; found {
u . Set ( "vlan" , v . ( string ) )
}
if v , found := p . p [ "zoneid" ] ; found {
u . Set ( "zoneid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * CreatePhysicalNetworkParams ) SetBroadcastdomainrange ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "broadcastdomainrange" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreatePhysicalNetworkParams ) SetDomainid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "domainid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreatePhysicalNetworkParams ) SetIsolationmethods ( v [ ] string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "isolationmethods" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * CreatePhysicalNetworkParams ) SetName ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "name" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * CreatePhysicalNetworkParams ) SetNetworkspeed ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "networkspeed" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * CreatePhysicalNetworkParams ) SetTags ( v [ ] string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "tags" ] = v
return
}
func ( p * CreatePhysicalNetworkParams ) SetVlan ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "vlan" ] = v
return
}
func ( p * CreatePhysicalNetworkParams ) SetZoneid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "zoneid" ] = v
return
}
// You should always use this function to get a new CreatePhysicalNetworkParams instance,
// as then you are sure you have configured all required params
func ( s * NetworkService ) NewCreatePhysicalNetworkParams ( name string , zoneid string ) * CreatePhysicalNetworkParams {
p := & CreatePhysicalNetworkParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "name" ] = name
p . p [ "zoneid" ] = zoneid
return p
}
// Creates a physical network
func ( s * NetworkService ) CreatePhysicalNetwork ( p * CreatePhysicalNetworkParams ) ( * CreatePhysicalNetworkResponse , error ) {
resp , err := s . cs . newRequest ( "createPhysicalNetwork" , p . toURLValues ( ) )
if err != nil {
return nil , err
}
var r CreatePhysicalNetworkResponse
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
// If we have a async client, we need to wait for the async result
2016-10-07 10:39:28 -04:00
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
2019-02-01 14:26:40 -05:00
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
2019-02-01 14:26:40 -05:00
return & r , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type CreatePhysicalNetworkResponse struct {
Broadcastdomainrange string ` json:"broadcastdomainrange" `
Domainid string ` json:"domainid" `
Id string ` json:"id" `
Isolationmethods string ` json:"isolationmethods" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Networkspeed string ` json:"networkspeed" `
State string ` json:"state" `
Tags string ` json:"tags" `
Vlan string ` json:"vlan" `
Zoneid string ` json:"zoneid" `
}
type CreateServiceInstanceParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * CreateServiceInstanceParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "account" ] ; found {
u . Set ( "account" , v . ( string ) )
}
if v , found := p . p [ "domainid" ] ; found {
u . Set ( "domainid" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "leftnetworkid" ] ; found {
u . Set ( "leftnetworkid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "name" ] ; found {
u . Set ( "name" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
if v , found := p . p [ "projectid" ] ; found {
u . Set ( "projectid" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "rightnetworkid" ] ; found {
u . Set ( "rightnetworkid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "serviceofferingid" ] ; found {
u . Set ( "serviceofferingid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "templateid" ] ; found {
u . Set ( "templateid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
if v , found := p . p [ "zoneid" ] ; found {
u . Set ( "zoneid" , v . ( string ) )
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * CreateServiceInstanceParams ) SetAccount ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "account" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateServiceInstanceParams ) SetDomainid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "domainid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateServiceInstanceParams ) SetLeftnetworkid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "leftnetworkid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateServiceInstanceParams ) SetName ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "name" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateServiceInstanceParams ) SetProjectid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "projectid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateServiceInstanceParams ) SetRightnetworkid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "rightnetworkid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateServiceInstanceParams ) SetServiceofferingid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "serviceofferingid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateServiceInstanceParams ) SetTemplateid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "templateid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateServiceInstanceParams ) SetZoneid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "zoneid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new CreateServiceInstanceParams instance,
// as then you are sure you have configured all required params
func ( s * NetworkService ) NewCreateServiceInstanceParams ( leftnetworkid string , name string , rightnetworkid string , serviceofferingid string , templateid string , zoneid string ) * CreateServiceInstanceParams {
p := & CreateServiceInstanceParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "leftnetworkid" ] = leftnetworkid
p . p [ "name" ] = name
p . p [ "rightnetworkid" ] = rightnetworkid
p . p [ "serviceofferingid" ] = serviceofferingid
p . p [ "templateid" ] = templateid
p . p [ "zoneid" ] = zoneid
return p
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// Creates a system virtual-machine that implements network services
func ( s * NetworkService ) CreateServiceInstance ( p * CreateServiceInstanceParams ) ( * CreateServiceInstanceResponse , error ) {
resp , err := s . cs . newRequest ( "createServiceInstance" , p . toURLValues ( ) )
if err != nil {
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
var r CreateServiceInstanceResponse
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
return & r , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type CreateServiceInstanceResponse struct {
Account string ` json:"account" `
Displayname string ` json:"displayname" `
Domain string ` json:"domain" `
Domainid string ` json:"domainid" `
Id string ` json:"id" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Project string ` json:"project" `
Projectid string ` json:"projectid" `
}
type CreateStorageNetworkIpRangeParams struct {
p map [ string ] interface { }
}
func ( p * CreateStorageNetworkIpRangeParams ) toURLValues ( ) url . Values {
u := url . Values { }
2016-10-07 10:39:28 -04:00
if p . p == nil {
2019-02-01 14:26:40 -05:00
return u
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "endip" ] ; found {
u . Set ( "endip" , v . ( string ) )
}
if v , found := p . p [ "gateway" ] ; found {
u . Set ( "gateway" , v . ( string ) )
}
if v , found := p . p [ "netmask" ] ; found {
u . Set ( "netmask" , v . ( string ) )
}
if v , found := p . p [ "podid" ] ; found {
u . Set ( "podid" , v . ( string ) )
}
if v , found := p . p [ "startip" ] ; found {
u . Set ( "startip" , v . ( string ) )
}
if v , found := p . p [ "vlan" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "vlan" , vv )
}
return u
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * CreateStorageNetworkIpRangeParams ) SetEndip ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "endip" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateStorageNetworkIpRangeParams ) SetGateway ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "gateway" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateStorageNetworkIpRangeParams ) SetNetmask ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "netmask" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateStorageNetworkIpRangeParams ) SetPodid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "podid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateStorageNetworkIpRangeParams ) SetStartip ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "startip" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * CreateStorageNetworkIpRangeParams ) SetVlan ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "vlan" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new CreateStorageNetworkIpRangeParams instance,
// as then you are sure you have configured all required params
func ( s * NetworkService ) NewCreateStorageNetworkIpRangeParams ( gateway string , netmask string , podid string , startip string ) * CreateStorageNetworkIpRangeParams {
p := & CreateStorageNetworkIpRangeParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "gateway" ] = gateway
p . p [ "netmask" ] = netmask
p . p [ "podid" ] = podid
p . p [ "startip" ] = startip
return p
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// Creates a Storage network IP range.
func ( s * NetworkService ) CreateStorageNetworkIpRange ( p * CreateStorageNetworkIpRangeParams ) ( * CreateStorageNetworkIpRangeResponse , error ) {
resp , err := s . cs . newRequest ( "createStorageNetworkIpRange" , p . toURLValues ( ) )
if err != nil {
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
var r CreateStorageNetworkIpRangeResponse
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return & r , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type CreateStorageNetworkIpRangeResponse struct {
Endip string ` json:"endip" `
Gateway string ` json:"gateway" `
Id string ` json:"id" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Netmask string ` json:"netmask" `
Networkid string ` json:"networkid" `
Podid string ` json:"podid" `
Startip string ` json:"startip" `
Vlan int ` json:"vlan" `
Zoneid string ` json:"zoneid" `
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
type DedicatePublicIpRangeParams struct {
p map [ string ] interface { }
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * DedicatePublicIpRangeParams ) toURLValues ( ) url . Values {
u := url . Values { }
if p . p == nil {
return u
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "account" ] ; found {
u . Set ( "account" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "domainid" ] ; found {
u . Set ( "domainid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "projectid" ] ; found {
u . Set ( "projectid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return u
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * DedicatePublicIpRangeParams ) SetAccount ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "account" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * DedicatePublicIpRangeParams ) SetDomainid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "domainid" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * DedicatePublicIpRangeParams ) SetId ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * DedicatePublicIpRangeParams ) SetProjectid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "projectid" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new DedicatePublicIpRangeParams instance,
// as then you are sure you have configured all required params
func ( s * NetworkService ) NewDedicatePublicIpRangeParams ( domainid string , id string ) * DedicatePublicIpRangeParams {
p := & DedicatePublicIpRangeParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "domainid" ] = domainid
p . p [ "id" ] = id
return p
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// Dedicates a Public IP range to an account
func ( s * NetworkService ) DedicatePublicIpRange ( p * DedicatePublicIpRangeParams ) ( * DedicatePublicIpRangeResponse , error ) {
resp , err := s . cs . newRequest ( "dedicatePublicIpRange" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r DedicatePublicIpRangeResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
return & r , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type DedicatePublicIpRangeResponse struct {
Account string ` json:"account" `
Description string ` json:"description" `
Domain string ` json:"domain" `
Domainid string ` json:"domainid" `
Endip string ` json:"endip" `
Endipv6 string ` json:"endipv6" `
Forsystemvms bool ` json:"forsystemvms" `
Forvirtualnetwork bool ` json:"forvirtualnetwork" `
Gateway string ` json:"gateway" `
Id string ` json:"id" `
Ip6cidr string ` json:"ip6cidr" `
Ip6gateway string ` json:"ip6gateway" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Netmask string ` json:"netmask" `
Networkid string ` json:"networkid" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Podid string ` json:"podid" `
Podname string ` json:"podname" `
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Startip string ` json:"startip" `
Startipv6 string ` json:"startipv6" `
Vlan string ` json:"vlan" `
Zoneid string ` json:"zoneid" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type DeleteNetworkParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * DeleteNetworkParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "forced" ] ; found {
2016-10-07 10:39:28 -04:00
vv := strconv . FormatBool ( v . ( bool ) )
2019-02-01 14:26:40 -05:00
u . Set ( "forced" , vv )
2016-10-07 10:39:28 -04:00
}
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * DeleteNetworkParams ) SetForced ( v bool ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "forced" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * DeleteNetworkParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "id" ] = v
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new DeleteNetworkParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewDeleteNetworkParams ( id string ) * DeleteNetworkParams {
p := & DeleteNetworkParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
p . p [ "id" ] = id
return p
}
2019-02-01 14:26:40 -05:00
// Deletes a network
func ( s * NetworkService ) DeleteNetwork ( p * DeleteNetworkParams ) ( * DeleteNetworkResponse , error ) {
resp , err := s . cs . newRequest ( "deleteNetwork" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r DeleteNetworkResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type DeleteNetworkResponse struct {
Displaytext string ` json:"displaytext" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Success bool ` json:"success" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type DeleteNetworkServiceProviderParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * DeleteNetworkServiceProviderParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * DeleteNetworkServiceProviderParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new DeleteNetworkServiceProviderParams instance,
// as then you are sure you have configured all required params
func ( s * NetworkService ) NewDeleteNetworkServiceProviderParams ( id string ) * DeleteNetworkServiceProviderParams {
p := & DeleteNetworkServiceProviderParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "id" ] = id
return p
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// Deletes a Network Service Provider.
func ( s * NetworkService ) DeleteNetworkServiceProvider ( p * DeleteNetworkServiceProviderParams ) ( * DeleteNetworkServiceProviderResponse , error ) {
resp , err := s . cs . newRequest ( "deleteNetworkServiceProvider" , p . toURLValues ( ) )
if err != nil {
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
var r DeleteNetworkServiceProviderResponse
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return & r , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type DeleteNetworkServiceProviderResponse struct {
Displaytext string ` json:"displaytext" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Success bool ` json:"success" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type DeleteOpenDaylightControllerParams struct {
p map [ string ] interface { }
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * DeleteOpenDaylightControllerParams ) toURLValues ( ) url . Values {
u := url . Values { }
2016-10-07 10:39:28 -04:00
if p . p == nil {
2019-02-01 14:26:40 -05:00
return u
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
return u
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * DeleteOpenDaylightControllerParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new DeleteOpenDaylightControllerParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewDeleteOpenDaylightControllerParams ( id string ) * DeleteOpenDaylightControllerParams {
p := & DeleteOpenDaylightControllerParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
p . p [ "id" ] = id
return p
}
2019-02-01 14:26:40 -05:00
// Removes an OpenDyalight controler
func ( s * NetworkService ) DeleteOpenDaylightController ( p * DeleteOpenDaylightControllerParams ) ( * DeleteOpenDaylightControllerResponse , error ) {
resp , err := s . cs . newRequest ( "deleteOpenDaylightController" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r DeleteOpenDaylightControllerResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type DeleteOpenDaylightControllerResponse struct {
Id string ` json:"id" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Url string ` json:"url" `
Username string ` json:"username" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type DeletePhysicalNetworkParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * DeletePhysicalNetworkParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * DeletePhysicalNetworkParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new DeletePhysicalNetworkParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewDeletePhysicalNetworkParams ( id string ) * DeletePhysicalNetworkParams {
p := & DeletePhysicalNetworkParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = id
2016-10-07 10:39:28 -04:00
return p
}
2019-02-01 14:26:40 -05:00
// Deletes a Physical Network.
func ( s * NetworkService ) DeletePhysicalNetwork ( p * DeletePhysicalNetworkParams ) ( * DeletePhysicalNetworkResponse , error ) {
resp , err := s . cs . newRequest ( "deletePhysicalNetwork" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r DeletePhysicalNetworkResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type DeletePhysicalNetworkResponse struct {
Displaytext string ` json:"displaytext" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Success bool ` json:"success" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type DeleteStorageNetworkIpRangeParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * DeleteStorageNetworkIpRangeParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * DeleteStorageNetworkIpRangeParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "id" ] = v
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new DeleteStorageNetworkIpRangeParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewDeleteStorageNetworkIpRangeParams ( id string ) * DeleteStorageNetworkIpRangeParams {
p := & DeleteStorageNetworkIpRangeParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
p . p [ "id" ] = id
return p
}
2019-02-01 14:26:40 -05:00
// Deletes a storage network IP Range.
func ( s * NetworkService ) DeleteStorageNetworkIpRange ( p * DeleteStorageNetworkIpRangeParams ) ( * DeleteStorageNetworkIpRangeResponse , error ) {
resp , err := s . cs . newRequest ( "deleteStorageNetworkIpRange" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r DeleteStorageNetworkIpRangeResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type DeleteStorageNetworkIpRangeResponse struct {
Displaytext string ` json:"displaytext" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Success bool ` json:"success" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type ListNetscalerLoadBalancerNetworksParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetscalerLoadBalancerNetworksParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "keyword" ] ; found {
u . Set ( "keyword" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "lbdeviceid" ] ; found {
u . Set ( "lbdeviceid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
if v , found := p . p [ "page" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "page" , vv )
}
if v , found := p . p [ "pagesize" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "pagesize" , vv )
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetscalerLoadBalancerNetworksParams ) SetKeyword ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "keyword" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetscalerLoadBalancerNetworksParams ) SetLbdeviceid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "lbdeviceid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetscalerLoadBalancerNetworksParams ) SetPage ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "page" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetscalerLoadBalancerNetworksParams ) SetPagesize ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "pagesize" ] = v
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new ListNetscalerLoadBalancerNetworksParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewListNetscalerLoadBalancerNetworksParams ( lbdeviceid string ) * ListNetscalerLoadBalancerNetworksParams {
p := & ListNetscalerLoadBalancerNetworksParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "lbdeviceid" ] = lbdeviceid
2016-10-07 10:39:28 -04:00
return p
}
// This is a courtesy helper function, which in some cases may not work as expected!
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) GetNetscalerLoadBalancerNetworkID ( keyword string , lbdeviceid string , opts ... OptionFunc ) ( string , int , error ) {
p := & ListNetscalerLoadBalancerNetworksParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "keyword" ] = keyword
p . p [ "lbdeviceid" ] = lbdeviceid
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
for _ , fn := range append ( s . cs . options , opts ... ) {
2016-10-07 10:39:28 -04:00
if err := fn ( s . cs , p ) ; err != nil {
return "" , - 1 , err
}
}
2019-02-01 14:26:40 -05:00
l , err := s . ListNetscalerLoadBalancerNetworks ( p )
2016-10-07 10:39:28 -04:00
if err != nil {
return "" , - 1 , err
}
if l . Count == 0 {
2019-02-01 14:26:40 -05:00
return "" , l . Count , fmt . Errorf ( "No match found for %s: %+v" , keyword , l )
2016-10-07 10:39:28 -04:00
}
if l . Count == 1 {
2019-02-01 14:26:40 -05:00
return l . NetscalerLoadBalancerNetworks [ 0 ] . Id , l . Count , nil
2016-10-07 10:39:28 -04:00
}
if l . Count > 1 {
2019-02-01 14:26:40 -05:00
for _ , v := range l . NetscalerLoadBalancerNetworks {
if v . Name == keyword {
2016-10-07 10:39:28 -04:00
return v . Id , l . Count , nil
}
}
}
2019-02-01 14:26:40 -05:00
return "" , l . Count , fmt . Errorf ( "Could not find an exact match for %s: %+v" , keyword , l )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// lists network that are using a netscaler load balancer device
func ( s * NetworkService ) ListNetscalerLoadBalancerNetworks ( p * ListNetscalerLoadBalancerNetworksParams ) ( * ListNetscalerLoadBalancerNetworksResponse , error ) {
resp , err := s . cs . newRequest ( "listNetscalerLoadBalancerNetworks" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r ListNetscalerLoadBalancerNetworksResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListNetscalerLoadBalancerNetworksResponse struct {
Count int ` json:"count" `
NetscalerLoadBalancerNetworks [ ] * NetscalerLoadBalancerNetwork ` json:"netscalerloadbalancernetwork" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type NetscalerLoadBalancerNetwork struct {
Account string ` json:"account" `
Aclid string ` json:"aclid" `
Acltype string ` json:"acltype" `
Broadcastdomaintype string ` json:"broadcastdomaintype" `
Broadcasturi string ` json:"broadcasturi" `
Canusefordeploy bool ` json:"canusefordeploy" `
Cidr string ` json:"cidr" `
Displaynetwork bool ` json:"displaynetwork" `
Displaytext string ` json:"displaytext" `
Dns1 string ` json:"dns1" `
Dns2 string ` json:"dns2" `
Domain string ` json:"domain" `
Domainid string ` json:"domainid" `
Externalid string ` json:"externalid" `
Gateway string ` json:"gateway" `
Id string ` json:"id" `
Ip6cidr string ` json:"ip6cidr" `
Ip6gateway string ` json:"ip6gateway" `
Isdefault bool ` json:"isdefault" `
Ispersistent bool ` json:"ispersistent" `
Issystem bool ` json:"issystem" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Netmask string ` json:"netmask" `
Networkcidr string ` json:"networkcidr" `
Networkdomain string ` json:"networkdomain" `
Networkofferingavailability string ` json:"networkofferingavailability" `
Networkofferingconservemode bool ` json:"networkofferingconservemode" `
Networkofferingdisplaytext string ` json:"networkofferingdisplaytext" `
Networkofferingid string ` json:"networkofferingid" `
Networkofferingname string ` json:"networkofferingname" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Redundantrouter bool ` json:"redundantrouter" `
Related string ` json:"related" `
Reservediprange string ` json:"reservediprange" `
Restartrequired bool ` json:"restartrequired" `
Service [ ] NetscalerLoadBalancerNetworkService ` json:"service" `
Specifyipranges bool ` json:"specifyipranges" `
State string ` json:"state" `
Strechedl2subnet bool ` json:"strechedl2subnet" `
Subdomainaccess bool ` json:"subdomainaccess" `
Tags [ ] Tags ` json:"tags" `
Traffictype string ` json:"traffictype" `
Type string ` json:"type" `
Vlan string ` json:"vlan" `
Vpcid string ` json:"vpcid" `
Zoneid string ` json:"zoneid" `
Zonename string ` json:"zonename" `
Zonesnetworkspans [ ] interface { } ` json:"zonesnetworkspans" `
}
type NetscalerLoadBalancerNetworkService struct {
Capability [ ] NetscalerLoadBalancerNetworkServiceCapability ` json:"capability" `
Name string ` json:"name" `
Provider [ ] NetscalerLoadBalancerNetworkServiceProvider ` json:"provider" `
}
type NetscalerLoadBalancerNetworkServiceProvider struct {
Canenableindividualservice bool ` json:"canenableindividualservice" `
Destinationphysicalnetworkid string ` json:"destinationphysicalnetworkid" `
Id string ` json:"id" `
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Servicelist [ ] string ` json:"servicelist" `
State string ` json:"state" `
}
type NetscalerLoadBalancerNetworkServiceCapability struct {
Canchooseservicecapability bool ` json:"canchooseservicecapability" `
Name string ` json:"name" `
Value string ` json:"value" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type ListNetworkIsolationMethodsParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworkIsolationMethodsParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "keyword" ] ; found {
u . Set ( "keyword" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "page" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "page" , vv )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "pagesize" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "pagesize" , vv )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworkIsolationMethodsParams ) SetKeyword ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "keyword" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworkIsolationMethodsParams ) SetPage ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "page" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworkIsolationMethodsParams ) SetPagesize ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "pagesize" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new ListNetworkIsolationMethodsParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewListNetworkIsolationMethodsParams ( ) * ListNetworkIsolationMethodsParams {
p := & ListNetworkIsolationMethodsParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
return p
}
2019-02-01 14:26:40 -05:00
// Lists supported methods of network isolation
func ( s * NetworkService ) ListNetworkIsolationMethods ( p * ListNetworkIsolationMethodsParams ) ( * ListNetworkIsolationMethodsResponse , error ) {
resp , err := s . cs . newRequest ( "listNetworkIsolationMethods" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r ListNetworkIsolationMethodsResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListNetworkIsolationMethodsResponse struct {
Count int ` json:"count" `
NetworkIsolationMethods [ ] * NetworkIsolationMethod ` json:"networkisolationmethod" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type NetworkIsolationMethod struct {
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
Name string ` json:"name" `
2019-02-01 14:26:40 -05:00
}
type ListNetworkServiceProvidersParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworkServiceProvidersParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "keyword" ] ; found {
u . Set ( "keyword" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "name" ] ; found {
u . Set ( "name" , v . ( string ) )
}
2016-10-07 10:39:28 -04:00
if v , found := p . p [ "page" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "page" , vv )
}
if v , found := p . p [ "pagesize" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "pagesize" , vv )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "physicalnetworkid" ] ; found {
u . Set ( "physicalnetworkid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "state" ] ; found {
u . Set ( "state" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworkServiceProvidersParams ) SetKeyword ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "keyword" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworkServiceProvidersParams ) SetName ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "name" ] = v
return
}
func ( p * ListNetworkServiceProvidersParams ) SetPage ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "page" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworkServiceProvidersParams ) SetPagesize ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "pagesize" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworkServiceProvidersParams ) SetPhysicalnetworkid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "physicalnetworkid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworkServiceProvidersParams ) SetState ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "state" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new ListNetworkServiceProvidersParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewListNetworkServiceProvidersParams ( ) * ListNetworkServiceProvidersParams {
p := & ListNetworkServiceProvidersParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
return p
}
2019-02-01 14:26:40 -05:00
// This is a courtesy helper function, which in some cases may not work as expected!
func ( s * NetworkService ) GetNetworkServiceProviderID ( name string , opts ... OptionFunc ) ( string , int , error ) {
p := & ListNetworkServiceProvidersParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "name" ] = name
for _ , fn := range append ( s . cs . options , opts ... ) {
if err := fn ( s . cs , p ) ; err != nil {
return "" , - 1 , err
}
}
l , err := s . ListNetworkServiceProviders ( p )
if err != nil {
return "" , - 1 , err
}
if l . Count == 0 {
return "" , l . Count , fmt . Errorf ( "No match found for %s: %+v" , name , l )
}
if l . Count == 1 {
return l . NetworkServiceProviders [ 0 ] . Id , l . Count , nil
}
if l . Count > 1 {
for _ , v := range l . NetworkServiceProviders {
if v . Name == name {
return v . Id , l . Count , nil
}
}
}
return "" , l . Count , fmt . Errorf ( "Could not find an exact match for %s: %+v" , name , l )
}
// Lists network serviceproviders for a given physical network.
func ( s * NetworkService ) ListNetworkServiceProviders ( p * ListNetworkServiceProvidersParams ) ( * ListNetworkServiceProvidersResponse , error ) {
resp , err := s . cs . newRequest ( "listNetworkServiceProviders" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r ListNetworkServiceProvidersResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListNetworkServiceProvidersResponse struct {
Count int ` json:"count" `
NetworkServiceProviders [ ] * NetworkServiceProvider ` json:"networkserviceprovider" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type NetworkServiceProvider struct {
Canenableindividualservice bool ` json:"canenableindividualservice" `
Destinationphysicalnetworkid string ` json:"destinationphysicalnetworkid" `
Id string ` json:"id" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Servicelist [ ] string ` json:"servicelist" `
State string ` json:"state" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type ListNetworksParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "account" ] ; found {
u . Set ( "account" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "acltype" ] ; found {
u . Set ( "acltype" , v . ( string ) )
}
if v , found := p . p [ "canusefordeploy" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "canusefordeploy" , vv )
}
if v , found := p . p [ "displaynetwork" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "displaynetwork" , vv )
}
if v , found := p . p [ "domainid" ] ; found {
u . Set ( "domainid" , v . ( string ) )
}
if v , found := p . p [ "forvpc" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "forvpc" , vv )
}
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
if v , found := p . p [ "isrecursive" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "isrecursive" , vv )
}
if v , found := p . p [ "issystem" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "issystem" , vv )
}
if v , found := p . p [ "keyword" ] ; found {
u . Set ( "keyword" , v . ( string ) )
}
if v , found := p . p [ "listall" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "listall" , vv )
}
if v , found := p . p [ "page" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "page" , vv )
}
if v , found := p . p [ "pagesize" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "pagesize" , vv )
2016-10-07 10:39:28 -04:00
}
if v , found := p . p [ "physicalnetworkid" ] ; found {
u . Set ( "physicalnetworkid" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "projectid" ] ; found {
u . Set ( "projectid" , v . ( string ) )
}
if v , found := p . p [ "restartrequired" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "restartrequired" , vv )
}
if v , found := p . p [ "specifyipranges" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "specifyipranges" , vv )
}
if v , found := p . p [ "supportedservices" ] ; found {
2016-10-07 10:39:28 -04:00
vv := strings . Join ( v . ( [ ] string ) , "," )
2019-02-01 14:26:40 -05:00
u . Set ( "supportedservices" , vv )
}
if v , found := p . p [ "tags" ] ; found {
i := 0
for k , vv := range v . ( map [ string ] string ) {
u . Set ( fmt . Sprintf ( "tags[%d].key" , i ) , k )
u . Set ( fmt . Sprintf ( "tags[%d].value" , i ) , vv )
i ++
}
}
if v , found := p . p [ "traffictype" ] ; found {
u . Set ( "traffictype" , v . ( string ) )
}
if v , found := p . p [ "type" ] ; found {
u . Set ( "type" , v . ( string ) )
}
if v , found := p . p [ "vpcid" ] ; found {
u . Set ( "vpcid" , v . ( string ) )
}
if v , found := p . p [ "zoneid" ] ; found {
u . Set ( "zoneid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetAccount ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "account" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetAcltype ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "acltype" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetCanusefordeploy ( v bool ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "canusefordeploy" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetDisplaynetwork ( v bool ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "displaynetwork" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetDomainid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "domainid" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetForvpc ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "forvpc" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetId ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetIsrecursive ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "isrecursive" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetIssystem ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "issystem" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetKeyword ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "keyword" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetListall ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "listall" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetPage ( v int ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "page" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetPagesize ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
2019-02-01 14:26:40 -05:00
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "pagesize" ] = v
return
}
func ( p * ListNetworksParams ) SetPhysicalnetworkid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "physicalnetworkid" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetProjectid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "projectid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNetworksParams ) SetRestartrequired ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "restartrequired" ] = v
return
}
func ( p * ListNetworksParams ) SetSpecifyipranges ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "specifyipranges" ] = v
return
}
func ( p * ListNetworksParams ) SetSupportedservices ( v [ ] string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "supportedservices" ] = v
return
}
func ( p * ListNetworksParams ) SetTags ( v map [ string ] string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "tags" ] = v
return
}
func ( p * ListNetworksParams ) SetTraffictype ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "traffictype" ] = v
return
}
func ( p * ListNetworksParams ) SetType ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "type" ] = v
return
}
func ( p * ListNetworksParams ) SetVpcid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "vpcid" ] = v
return
}
func ( p * ListNetworksParams ) SetZoneid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "zoneid" ] = v
return
}
// You should always use this function to get a new ListNetworksParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewListNetworksParams ( ) * ListNetworksParams {
p := & ListNetworksParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
return p
}
2019-02-01 14:26:40 -05:00
// This is a courtesy helper function, which in some cases may not work as expected!
func ( s * NetworkService ) GetNetworkID ( keyword string , opts ... OptionFunc ) ( string , int , error ) {
p := & ListNetworksParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "keyword" ] = keyword
for _ , fn := range append ( s . cs . options , opts ... ) {
if err := fn ( s . cs , p ) ; err != nil {
return "" , - 1 , err
}
}
l , err := s . ListNetworks ( p )
2016-10-07 10:39:28 -04:00
if err != nil {
2019-02-01 14:26:40 -05:00
return "" , - 1 , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if l . Count == 0 {
return "" , l . Count , fmt . Errorf ( "No match found for %s: %+v" , keyword , l )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if l . Count == 1 {
return l . Networks [ 0 ] . Id , l . Count , nil
}
if l . Count > 1 {
for _ , v := range l . Networks {
if v . Name == keyword {
return v . Id , l . Count , nil
2016-10-07 10:39:28 -04:00
}
}
2019-02-01 14:26:40 -05:00
}
return "" , l . Count , fmt . Errorf ( "Could not find an exact match for %s: %+v" , keyword , l )
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
// This is a courtesy helper function, which in some cases may not work as expected!
func ( s * NetworkService ) GetNetworkByName ( name string , opts ... OptionFunc ) ( * Network , int , error ) {
id , count , err := s . GetNetworkID ( name , opts ... )
if err != nil {
return nil , count , err
}
r , count , err := s . GetNetworkByID ( id , opts ... )
if err != nil {
return nil , count , err
}
return r , count , nil
}
// This is a courtesy helper function, which in some cases may not work as expected!
func ( s * NetworkService ) GetNetworkByID ( id string , opts ... OptionFunc ) ( * Network , int , error ) {
p := & ListNetworksParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "id" ] = id
for _ , fn := range append ( s . cs . options , opts ... ) {
if err := fn ( s . cs , p ) ; err != nil {
return nil , - 1 , err
}
}
l , err := s . ListNetworks ( p )
if err != nil {
if strings . Contains ( err . Error ( ) , fmt . Sprintf (
"Invalid parameter id value=%s due to incorrect long value format, " +
"or entity does not exist" , id ) ) {
return nil , 0 , fmt . Errorf ( "No match found for %s: %+v" , id , l )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return nil , - 1 , err
}
if l . Count == 0 {
return nil , l . Count , fmt . Errorf ( "No match found for %s: %+v" , id , l )
}
if l . Count == 1 {
return l . Networks [ 0 ] , l . Count , nil
}
return nil , l . Count , fmt . Errorf ( "There is more then one result for Network UUID: %s!" , id )
}
// Lists all available networks.
func ( s * NetworkService ) ListNetworks ( p * ListNetworksParams ) ( * ListNetworksResponse , error ) {
resp , err := s . cs . newRequest ( "listNetworks" , p . toURLValues ( ) )
if err != nil {
return nil , err
}
var r ListNetworksResponse
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListNetworksResponse struct {
Count int ` json:"count" `
Networks [ ] * Network ` json:"network" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type Network struct {
Account string ` json:"account" `
Aclid string ` json:"aclid" `
Acltype string ` json:"acltype" `
Broadcastdomaintype string ` json:"broadcastdomaintype" `
Broadcasturi string ` json:"broadcasturi" `
Canusefordeploy bool ` json:"canusefordeploy" `
Cidr string ` json:"cidr" `
Displaynetwork bool ` json:"displaynetwork" `
Displaytext string ` json:"displaytext" `
Dns1 string ` json:"dns1" `
Dns2 string ` json:"dns2" `
Domain string ` json:"domain" `
Domainid string ` json:"domainid" `
Externalid string ` json:"externalid" `
Gateway string ` json:"gateway" `
Id string ` json:"id" `
Ip6cidr string ` json:"ip6cidr" `
Ip6gateway string ` json:"ip6gateway" `
Isdefault bool ` json:"isdefault" `
Ispersistent bool ` json:"ispersistent" `
Issystem bool ` json:"issystem" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Netmask string ` json:"netmask" `
Networkcidr string ` json:"networkcidr" `
Networkdomain string ` json:"networkdomain" `
Networkofferingavailability string ` json:"networkofferingavailability" `
Networkofferingconservemode bool ` json:"networkofferingconservemode" `
Networkofferingdisplaytext string ` json:"networkofferingdisplaytext" `
Networkofferingid string ` json:"networkofferingid" `
Networkofferingname string ` json:"networkofferingname" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Redundantrouter bool ` json:"redundantrouter" `
Related string ` json:"related" `
Reservediprange string ` json:"reservediprange" `
Restartrequired bool ` json:"restartrequired" `
Service [ ] NetworkServiceInternal ` json:"service" `
Specifyipranges bool ` json:"specifyipranges" `
State string ` json:"state" `
Strechedl2subnet bool ` json:"strechedl2subnet" `
Subdomainaccess bool ` json:"subdomainaccess" `
Tags [ ] Tags ` json:"tags" `
Traffictype string ` json:"traffictype" `
Type string ` json:"type" `
Vlan string ` json:"vlan" `
Vpcid string ` json:"vpcid" `
Zoneid string ` json:"zoneid" `
Zonename string ` json:"zonename" `
Zonesnetworkspans [ ] interface { } ` json:"zonesnetworkspans" `
}
type NetworkServiceInternal struct {
Capability [ ] NetworkServiceInternalCapability ` json:"capability" `
Name string ` json:"name" `
Provider [ ] NetworkServiceInternalProvider ` json:"provider" `
}
type NetworkServiceInternalProvider struct {
Canenableindividualservice bool ` json:"canenableindividualservice" `
Destinationphysicalnetworkid string ` json:"destinationphysicalnetworkid" `
Id string ` json:"id" `
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Servicelist [ ] string ` json:"servicelist" `
State string ` json:"state" `
}
type NetworkServiceInternalCapability struct {
Canchooseservicecapability bool ` json:"canchooseservicecapability" `
Name string ` json:"name" `
Value string ` json:"value" `
}
type ListNiciraNvpDeviceNetworksParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * ListNiciraNvpDeviceNetworksParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "keyword" ] ; found {
u . Set ( "keyword" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "nvpdeviceid" ] ; found {
u . Set ( "nvpdeviceid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
if v , found := p . p [ "page" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "page" , vv )
}
if v , found := p . p [ "pagesize" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "pagesize" , vv )
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * ListNiciraNvpDeviceNetworksParams ) SetKeyword ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "keyword" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNiciraNvpDeviceNetworksParams ) SetNvpdeviceid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "nvpdeviceid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNiciraNvpDeviceNetworksParams ) SetPage ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "page" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListNiciraNvpDeviceNetworksParams ) SetPagesize ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "pagesize" ] = v
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new ListNiciraNvpDeviceNetworksParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewListNiciraNvpDeviceNetworksParams ( nvpdeviceid string ) * ListNiciraNvpDeviceNetworksParams {
p := & ListNiciraNvpDeviceNetworksParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "nvpdeviceid" ] = nvpdeviceid
2016-10-07 10:39:28 -04:00
return p
}
// This is a courtesy helper function, which in some cases may not work as expected!
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) GetNiciraNvpDeviceNetworkID ( keyword string , nvpdeviceid string , opts ... OptionFunc ) ( string , int , error ) {
p := & ListNiciraNvpDeviceNetworksParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "keyword" ] = keyword
p . p [ "nvpdeviceid" ] = nvpdeviceid
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
for _ , fn := range append ( s . cs . options , opts ... ) {
2016-10-07 10:39:28 -04:00
if err := fn ( s . cs , p ) ; err != nil {
return "" , - 1 , err
}
}
2019-02-01 14:26:40 -05:00
l , err := s . ListNiciraNvpDeviceNetworks ( p )
2016-10-07 10:39:28 -04:00
if err != nil {
return "" , - 1 , err
}
if l . Count == 0 {
2019-02-01 14:26:40 -05:00
return "" , l . Count , fmt . Errorf ( "No match found for %s: %+v" , keyword , l )
2016-10-07 10:39:28 -04:00
}
if l . Count == 1 {
2019-02-01 14:26:40 -05:00
return l . NiciraNvpDeviceNetworks [ 0 ] . Id , l . Count , nil
2016-10-07 10:39:28 -04:00
}
if l . Count > 1 {
2019-02-01 14:26:40 -05:00
for _ , v := range l . NiciraNvpDeviceNetworks {
if v . Name == keyword {
2016-10-07 10:39:28 -04:00
return v . Id , l . Count , nil
}
}
}
2019-02-01 14:26:40 -05:00
return "" , l . Count , fmt . Errorf ( "Could not find an exact match for %s: %+v" , keyword , l )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// lists network that are using a nicira nvp device
func ( s * NetworkService ) ListNiciraNvpDeviceNetworks ( p * ListNiciraNvpDeviceNetworksParams ) ( * ListNiciraNvpDeviceNetworksResponse , error ) {
resp , err := s . cs . newRequest ( "listNiciraNvpDeviceNetworks" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r ListNiciraNvpDeviceNetworksResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListNiciraNvpDeviceNetworksResponse struct {
2016-10-07 10:39:28 -04:00
Count int ` json:"count" `
2019-02-01 14:26:40 -05:00
NiciraNvpDeviceNetworks [ ] * NiciraNvpDeviceNetwork ` json:"niciranvpdevicenetwork" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type NiciraNvpDeviceNetwork struct {
Account string ` json:"account" `
Aclid string ` json:"aclid" `
Acltype string ` json:"acltype" `
Broadcastdomaintype string ` json:"broadcastdomaintype" `
Broadcasturi string ` json:"broadcasturi" `
Canusefordeploy bool ` json:"canusefordeploy" `
Cidr string ` json:"cidr" `
Displaynetwork bool ` json:"displaynetwork" `
Displaytext string ` json:"displaytext" `
Dns1 string ` json:"dns1" `
Dns2 string ` json:"dns2" `
Domain string ` json:"domain" `
Domainid string ` json:"domainid" `
Externalid string ` json:"externalid" `
Gateway string ` json:"gateway" `
Id string ` json:"id" `
Ip6cidr string ` json:"ip6cidr" `
Ip6gateway string ` json:"ip6gateway" `
Isdefault bool ` json:"isdefault" `
Ispersistent bool ` json:"ispersistent" `
Issystem bool ` json:"issystem" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Netmask string ` json:"netmask" `
Networkcidr string ` json:"networkcidr" `
Networkdomain string ` json:"networkdomain" `
Networkofferingavailability string ` json:"networkofferingavailability" `
Networkofferingconservemode bool ` json:"networkofferingconservemode" `
Networkofferingdisplaytext string ` json:"networkofferingdisplaytext" `
Networkofferingid string ` json:"networkofferingid" `
Networkofferingname string ` json:"networkofferingname" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Redundantrouter bool ` json:"redundantrouter" `
Related string ` json:"related" `
Reservediprange string ` json:"reservediprange" `
Restartrequired bool ` json:"restartrequired" `
Service [ ] NiciraNvpDeviceNetworkService ` json:"service" `
Specifyipranges bool ` json:"specifyipranges" `
State string ` json:"state" `
Strechedl2subnet bool ` json:"strechedl2subnet" `
Subdomainaccess bool ` json:"subdomainaccess" `
Tags [ ] Tags ` json:"tags" `
Traffictype string ` json:"traffictype" `
Type string ` json:"type" `
Vlan string ` json:"vlan" `
Vpcid string ` json:"vpcid" `
Zoneid string ` json:"zoneid" `
Zonename string ` json:"zonename" `
Zonesnetworkspans [ ] interface { } ` json:"zonesnetworkspans" `
}
type NiciraNvpDeviceNetworkService struct {
Capability [ ] NiciraNvpDeviceNetworkServiceCapability ` json:"capability" `
Name string ` json:"name" `
Provider [ ] NiciraNvpDeviceNetworkServiceProvider ` json:"provider" `
}
type NiciraNvpDeviceNetworkServiceProvider struct {
Canenableindividualservice bool ` json:"canenableindividualservice" `
Destinationphysicalnetworkid string ` json:"destinationphysicalnetworkid" `
Id string ` json:"id" `
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Servicelist [ ] string ` json:"servicelist" `
State string ` json:"state" `
}
type NiciraNvpDeviceNetworkServiceCapability struct {
Canchooseservicecapability bool ` json:"canchooseservicecapability" `
Name string ` json:"name" `
Value string ` json:"value" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type ListOpenDaylightControllersParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * ListOpenDaylightControllersParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "physicalnetworkid" ] ; found {
u . Set ( "physicalnetworkid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * ListOpenDaylightControllersParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "id" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListOpenDaylightControllersParams ) SetPhysicalnetworkid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "physicalnetworkid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new ListOpenDaylightControllersParams instance,
// as then you are sure you have configured all required params
func ( s * NetworkService ) NewListOpenDaylightControllersParams ( ) * ListOpenDaylightControllersParams {
p := & ListOpenDaylightControllersParams { }
p . p = make ( map [ string ] interface { } )
return p
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// This is a courtesy helper function, which in some cases may not work as expected!
func ( s * NetworkService ) GetOpenDaylightControllerByID ( id string , opts ... OptionFunc ) ( * OpenDaylightController , int , error ) {
p := & ListOpenDaylightControllersParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
p . p [ "id" ] = id
2019-02-01 14:26:40 -05:00
for _ , fn := range append ( s . cs . options , opts ... ) {
if err := fn ( s . cs , p ) ; err != nil {
return nil , - 1 , err
}
}
l , err := s . ListOpenDaylightControllers ( p )
if err != nil {
if strings . Contains ( err . Error ( ) , fmt . Sprintf (
"Invalid parameter id value=%s due to incorrect long value format, " +
"or entity does not exist" , id ) ) {
return nil , 0 , fmt . Errorf ( "No match found for %s: %+v" , id , l )
}
return nil , - 1 , err
}
if l . Count == 0 {
return nil , l . Count , fmt . Errorf ( "No match found for %s: %+v" , id , l )
}
if l . Count == 1 {
return l . OpenDaylightControllers [ 0 ] , l . Count , nil
}
return nil , l . Count , fmt . Errorf ( "There is more then one result for OpenDaylightController UUID: %s!" , id )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// Lists OpenDyalight controllers
func ( s * NetworkService ) ListOpenDaylightControllers ( p * ListOpenDaylightControllersParams ) ( * ListOpenDaylightControllersResponse , error ) {
resp , err := s . cs . newRequest ( "listOpenDaylightControllers" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r ListOpenDaylightControllersResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListOpenDaylightControllersResponse struct {
Count int ` json:"count" `
OpenDaylightControllers [ ] * OpenDaylightController ` json:"opendaylightcontroller" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type OpenDaylightController struct {
Id string ` json:"id" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Url string ` json:"url" `
Username string ` json:"username" `
}
type ListPaloAltoFirewallNetworksParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * ListPaloAltoFirewallNetworksParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "keyword" ] ; found {
u . Set ( "keyword" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "lbdeviceid" ] ; found {
u . Set ( "lbdeviceid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "page" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "page" , vv )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "pagesize" ] ; found {
2016-10-07 10:39:28 -04:00
vv := strconv . Itoa ( v . ( int ) )
2019-02-01 14:26:40 -05:00
u . Set ( "pagesize" , vv )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * ListPaloAltoFirewallNetworksParams ) SetKeyword ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "keyword" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListPaloAltoFirewallNetworksParams ) SetLbdeviceid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "lbdeviceid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListPaloAltoFirewallNetworksParams ) SetPage ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "page" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListPaloAltoFirewallNetworksParams ) SetPagesize ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "pagesize" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new ListPaloAltoFirewallNetworksParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewListPaloAltoFirewallNetworksParams ( lbdeviceid string ) * ListPaloAltoFirewallNetworksParams {
p := & ListPaloAltoFirewallNetworksParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "lbdeviceid" ] = lbdeviceid
2016-10-07 10:39:28 -04:00
return p
}
2019-02-01 14:26:40 -05:00
// This is a courtesy helper function, which in some cases may not work as expected!
func ( s * NetworkService ) GetPaloAltoFirewallNetworkID ( keyword string , lbdeviceid string , opts ... OptionFunc ) ( string , int , error ) {
p := & ListPaloAltoFirewallNetworksParams { }
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
p . p [ "keyword" ] = keyword
p . p [ "lbdeviceid" ] = lbdeviceid
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
for _ , fn := range append ( s . cs . options , opts ... ) {
if err := fn ( s . cs , p ) ; err != nil {
return "" , - 1 , err
2016-10-07 10:39:28 -04:00
}
}
2019-02-01 14:26:40 -05:00
l , err := s . ListPaloAltoFirewallNetworks ( p )
if err != nil {
return "" , - 1 , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if l . Count == 0 {
return "" , l . Count , fmt . Errorf ( "No match found for %s: %+v" , keyword , l )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if l . Count == 1 {
return l . PaloAltoFirewallNetworks [ 0 ] . Id , l . Count , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if l . Count > 1 {
for _ , v := range l . PaloAltoFirewallNetworks {
if v . Name == keyword {
return v . Id , l . Count , nil
}
}
}
return "" , l . Count , fmt . Errorf ( "Could not find an exact match for %s: %+v" , keyword , l )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// lists network that are using Palo Alto firewall device
func ( s * NetworkService ) ListPaloAltoFirewallNetworks ( p * ListPaloAltoFirewallNetworksParams ) ( * ListPaloAltoFirewallNetworksResponse , error ) {
resp , err := s . cs . newRequest ( "listPaloAltoFirewallNetworks" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r ListPaloAltoFirewallNetworksResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListPaloAltoFirewallNetworksResponse struct {
Count int ` json:"count" `
PaloAltoFirewallNetworks [ ] * PaloAltoFirewallNetwork ` json:"paloaltofirewallnetwork" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type PaloAltoFirewallNetwork struct {
Account string ` json:"account" `
Aclid string ` json:"aclid" `
Acltype string ` json:"acltype" `
Broadcastdomaintype string ` json:"broadcastdomaintype" `
Broadcasturi string ` json:"broadcasturi" `
Canusefordeploy bool ` json:"canusefordeploy" `
Cidr string ` json:"cidr" `
Displaynetwork bool ` json:"displaynetwork" `
Displaytext string ` json:"displaytext" `
Dns1 string ` json:"dns1" `
Dns2 string ` json:"dns2" `
Domain string ` json:"domain" `
Domainid string ` json:"domainid" `
Externalid string ` json:"externalid" `
Gateway string ` json:"gateway" `
Id string ` json:"id" `
Ip6cidr string ` json:"ip6cidr" `
Ip6gateway string ` json:"ip6gateway" `
Isdefault bool ` json:"isdefault" `
Ispersistent bool ` json:"ispersistent" `
Issystem bool ` json:"issystem" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Netmask string ` json:"netmask" `
Networkcidr string ` json:"networkcidr" `
Networkdomain string ` json:"networkdomain" `
Networkofferingavailability string ` json:"networkofferingavailability" `
Networkofferingconservemode bool ` json:"networkofferingconservemode" `
Networkofferingdisplaytext string ` json:"networkofferingdisplaytext" `
Networkofferingid string ` json:"networkofferingid" `
Networkofferingname string ` json:"networkofferingname" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Redundantrouter bool ` json:"redundantrouter" `
Related string ` json:"related" `
Reservediprange string ` json:"reservediprange" `
Restartrequired bool ` json:"restartrequired" `
Service [ ] PaloAltoFirewallNetworkService ` json:"service" `
Specifyipranges bool ` json:"specifyipranges" `
State string ` json:"state" `
Strechedl2subnet bool ` json:"strechedl2subnet" `
Subdomainaccess bool ` json:"subdomainaccess" `
Tags [ ] Tags ` json:"tags" `
Traffictype string ` json:"traffictype" `
Type string ` json:"type" `
Vlan string ` json:"vlan" `
Vpcid string ` json:"vpcid" `
Zoneid string ` json:"zoneid" `
Zonename string ` json:"zonename" `
Zonesnetworkspans [ ] interface { } ` json:"zonesnetworkspans" `
}
type PaloAltoFirewallNetworkService struct {
Capability [ ] PaloAltoFirewallNetworkServiceCapability ` json:"capability" `
Name string ` json:"name" `
Provider [ ] PaloAltoFirewallNetworkServiceProvider ` json:"provider" `
}
type PaloAltoFirewallNetworkServiceProvider struct {
Canenableindividualservice bool ` json:"canenableindividualservice" `
Destinationphysicalnetworkid string ` json:"destinationphysicalnetworkid" `
Id string ` json:"id" `
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Servicelist [ ] string ` json:"servicelist" `
State string ` json:"state" `
}
type PaloAltoFirewallNetworkServiceCapability struct {
Canchooseservicecapability bool ` json:"canchooseservicecapability" `
Name string ` json:"name" `
Value string ` json:"value" `
}
type ListPhysicalNetworksParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * ListPhysicalNetworksParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
if v , found := p . p [ "keyword" ] ; found {
u . Set ( "keyword" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "name" ] ; found {
u . Set ( "name" , v . ( string ) )
}
2016-10-07 10:39:28 -04:00
if v , found := p . p [ "page" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "page" , vv )
}
if v , found := p . p [ "pagesize" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "pagesize" , vv )
}
if v , found := p . p [ "zoneid" ] ; found {
u . Set ( "zoneid" , v . ( string ) )
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * ListPhysicalNetworksParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "id" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListPhysicalNetworksParams ) SetKeyword ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "keyword" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListPhysicalNetworksParams ) SetName ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "name" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListPhysicalNetworksParams ) SetPage ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "page" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListPhysicalNetworksParams ) SetPagesize ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "pagesize" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListPhysicalNetworksParams ) SetZoneid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "zoneid" ] = v
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new ListPhysicalNetworksParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewListPhysicalNetworksParams ( ) * ListPhysicalNetworksParams {
p := & ListPhysicalNetworksParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
return p
}
// This is a courtesy helper function, which in some cases may not work as expected!
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) GetPhysicalNetworkID ( name string , opts ... OptionFunc ) ( string , int , error ) {
p := & ListPhysicalNetworksParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "name" ] = name
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
for _ , fn := range append ( s . cs . options , opts ... ) {
2016-10-07 10:39:28 -04:00
if err := fn ( s . cs , p ) ; err != nil {
2019-02-01 14:26:40 -05:00
return "" , - 1 , err
2016-10-07 10:39:28 -04:00
}
}
2019-02-01 14:26:40 -05:00
l , err := s . ListPhysicalNetworks ( p )
2016-10-07 10:39:28 -04:00
if err != nil {
2019-02-01 14:26:40 -05:00
return "" , - 1 , err
2016-10-07 10:39:28 -04:00
}
if l . Count == 0 {
2019-02-01 14:26:40 -05:00
return "" , l . Count , fmt . Errorf ( "No match found for %s: %+v" , name , l )
2016-10-07 10:39:28 -04:00
}
if l . Count == 1 {
2019-02-01 14:26:40 -05:00
return l . PhysicalNetworks [ 0 ] . Id , l . Count , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if l . Count > 1 {
for _ , v := range l . PhysicalNetworks {
if v . Name == name {
return v . Id , l . Count , nil
}
}
}
return "" , l . Count , fmt . Errorf ( "Could not find an exact match for %s: %+v" , name , l )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// This is a courtesy helper function, which in some cases may not work as expected!
func ( s * NetworkService ) GetPhysicalNetworkByName ( name string , opts ... OptionFunc ) ( * PhysicalNetwork , int , error ) {
id , count , err := s . GetPhysicalNetworkID ( name , opts ... )
2016-10-07 10:39:28 -04:00
if err != nil {
2019-02-01 14:26:40 -05:00
return nil , count , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
r , count , err := s . GetPhysicalNetworkByID ( id , opts ... )
if err != nil {
return nil , count , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return r , count , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// This is a courtesy helper function, which in some cases may not work as expected!
func ( s * NetworkService ) GetPhysicalNetworkByID ( id string , opts ... OptionFunc ) ( * PhysicalNetwork , int , error ) {
p := & ListPhysicalNetworksParams { }
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = id
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
for _ , fn := range append ( s . cs . options , opts ... ) {
if err := fn ( s . cs , p ) ; err != nil {
return nil , - 1 , err
}
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
l , err := s . ListPhysicalNetworks ( p )
if err != nil {
if strings . Contains ( err . Error ( ) , fmt . Sprintf (
"Invalid parameter id value=%s due to incorrect long value format, " +
"or entity does not exist" , id ) ) {
return nil , 0 , fmt . Errorf ( "No match found for %s: %+v" , id , l )
}
return nil , - 1 , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if l . Count == 0 {
return nil , l . Count , fmt . Errorf ( "No match found for %s: %+v" , id , l )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if l . Count == 1 {
return l . PhysicalNetworks [ 0 ] , l . Count , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return nil , l . Count , fmt . Errorf ( "There is more then one result for PhysicalNetwork UUID: %s!" , id )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// Lists physical networks
func ( s * NetworkService ) ListPhysicalNetworks ( p * ListPhysicalNetworksParams ) ( * ListPhysicalNetworksResponse , error ) {
resp , err := s . cs . newRequest ( "listPhysicalNetworks" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r ListPhysicalNetworksResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListPhysicalNetworksResponse struct {
Count int ` json:"count" `
PhysicalNetworks [ ] * PhysicalNetwork ` json:"physicalnetwork" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type PhysicalNetwork struct {
Broadcastdomainrange string ` json:"broadcastdomainrange" `
Domainid string ` json:"domainid" `
Id string ` json:"id" `
Isolationmethods string ` json:"isolationmethods" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Networkspeed string ` json:"networkspeed" `
State string ` json:"state" `
Tags string ` json:"tags" `
Vlan string ` json:"vlan" `
Zoneid string ` json:"zoneid" `
}
type ListStorageNetworkIpRangeParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * ListStorageNetworkIpRangeParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
2016-10-07 10:39:28 -04:00
if v , found := p . p [ "keyword" ] ; found {
u . Set ( "keyword" , v . ( string ) )
}
if v , found := p . p [ "page" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "page" , vv )
}
if v , found := p . p [ "pagesize" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "pagesize" , vv )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "podid" ] ; found {
u . Set ( "podid" , v . ( string ) )
}
if v , found := p . p [ "zoneid" ] ; found {
u . Set ( "zoneid" , v . ( string ) )
}
2016-10-07 10:39:28 -04:00
return u
}
2019-02-01 14:26:40 -05:00
func ( p * ListStorageNetworkIpRangeParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListStorageNetworkIpRangeParams ) SetKeyword ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "keyword" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListStorageNetworkIpRangeParams ) SetPage ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "page" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListStorageNetworkIpRangeParams ) SetPagesize ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "pagesize" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListStorageNetworkIpRangeParams ) SetPodid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "podid" ] = v
return
}
func ( p * ListStorageNetworkIpRangeParams ) SetZoneid ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "zoneid" ] = v
return
}
// You should always use this function to get a new ListStorageNetworkIpRangeParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewListStorageNetworkIpRangeParams ( ) * ListStorageNetworkIpRangeParams {
p := & ListStorageNetworkIpRangeParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
return p
}
// This is a courtesy helper function, which in some cases may not work as expected!
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) GetStorageNetworkIpRangeByID ( id string , opts ... OptionFunc ) ( * StorageNetworkIpRange , int , error ) {
p := & ListStorageNetworkIpRangeParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = id
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
for _ , fn := range append ( s . cs . options , opts ... ) {
2016-10-07 10:39:28 -04:00
if err := fn ( s . cs , p ) ; err != nil {
2019-02-01 14:26:40 -05:00
return nil , - 1 , err
2016-10-07 10:39:28 -04:00
}
}
2019-02-01 14:26:40 -05:00
l , err := s . ListStorageNetworkIpRange ( p )
2016-10-07 10:39:28 -04:00
if err != nil {
2019-02-01 14:26:40 -05:00
if strings . Contains ( err . Error ( ) , fmt . Sprintf (
"Invalid parameter id value=%s due to incorrect long value format, " +
"or entity does not exist" , id ) ) {
return nil , 0 , fmt . Errorf ( "No match found for %s: %+v" , id , l )
}
return nil , - 1 , err
2016-10-07 10:39:28 -04:00
}
if l . Count == 0 {
2019-02-01 14:26:40 -05:00
return nil , l . Count , fmt . Errorf ( "No match found for %s: %+v" , id , l )
2016-10-07 10:39:28 -04:00
}
if l . Count == 1 {
2019-02-01 14:26:40 -05:00
return l . StorageNetworkIpRange [ 0 ] , l . Count , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return nil , l . Count , fmt . Errorf ( "There is more then one result for StorageNetworkIpRange UUID: %s!" , id )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// List a storage network IP range.
func ( s * NetworkService ) ListStorageNetworkIpRange ( p * ListStorageNetworkIpRangeParams ) ( * ListStorageNetworkIpRangeResponse , error ) {
resp , err := s . cs . newRequest ( "listStorageNetworkIpRange" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r ListStorageNetworkIpRangeResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type ListStorageNetworkIpRangeResponse struct {
Count int ` json:"count" `
StorageNetworkIpRange [ ] * StorageNetworkIpRange ` json:"storagenetworkiprange" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type StorageNetworkIpRange struct {
Endip string ` json:"endip" `
Gateway string ` json:"gateway" `
Id string ` json:"id" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Netmask string ` json:"netmask" `
Networkid string ` json:"networkid" `
Podid string ` json:"podid" `
Startip string ` json:"startip" `
Vlan int ` json:"vlan" `
Zoneid string ` json:"zoneid" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type ListSupportedNetworkServicesParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * ListSupportedNetworkServicesParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "keyword" ] ; found {
u . Set ( "keyword" , v . ( string ) )
}
if v , found := p . p [ "page" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "page" , vv )
}
if v , found := p . p [ "pagesize" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "pagesize" , vv )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "provider" ] ; found {
u . Set ( "provider" , v . ( string ) )
}
if v , found := p . p [ "service" ] ; found {
u . Set ( "service" , v . ( string ) )
}
2016-10-07 10:39:28 -04:00
return u
}
2019-02-01 14:26:40 -05:00
func ( p * ListSupportedNetworkServicesParams ) SetKeyword ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "keyword" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListSupportedNetworkServicesParams ) SetPage ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "page" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListSupportedNetworkServicesParams ) SetPagesize ( v int ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "pagesize" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListSupportedNetworkServicesParams ) SetProvider ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "provider" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * ListSupportedNetworkServicesParams ) SetService ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "service" ] = v
return
}
// You should always use this function to get a new ListSupportedNetworkServicesParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewListSupportedNetworkServicesParams ( ) * ListSupportedNetworkServicesParams {
p := & ListSupportedNetworkServicesParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
return p
}
2019-02-01 14:26:40 -05:00
// Lists all network services provided by CloudStack or for the given Provider.
func ( s * NetworkService ) ListSupportedNetworkServices ( p * ListSupportedNetworkServicesParams ) ( * ListSupportedNetworkServicesResponse , error ) {
resp , err := s . cs . newRequest ( "listSupportedNetworkServices" , p . toURLValues ( ) )
if err != nil {
return nil , err
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
var r ListSupportedNetworkServicesResponse
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
return & r , nil
}
type ListSupportedNetworkServicesResponse struct {
Count int ` json:"count" `
SupportedNetworkServices [ ] * SupportedNetworkService ` json:"supportednetworkservice" `
}
type SupportedNetworkService struct {
Capability [ ] SupportedNetworkServiceCapability ` json:"capability" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Provider [ ] SupportedNetworkServiceProvider ` json:"provider" `
}
type SupportedNetworkServiceProvider struct {
Canenableindividualservice bool ` json:"canenableindividualservice" `
Destinationphysicalnetworkid string ` json:"destinationphysicalnetworkid" `
Id string ` json:"id" `
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Servicelist [ ] string ` json:"servicelist" `
State string ` json:"state" `
}
type SupportedNetworkServiceCapability struct {
Canchooseservicecapability bool ` json:"canchooseservicecapability" `
Name string ` json:"name" `
Value string ` json:"value" `
}
type ReleasePublicIpRangeParams struct {
p map [ string ] interface { }
}
func ( p * ReleasePublicIpRangeParams ) toURLValues ( ) url . Values {
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return u
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * ReleasePublicIpRangeParams ) SetId ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "id" ] = v
return
}
// You should always use this function to get a new ReleasePublicIpRangeParams instance,
// as then you are sure you have configured all required params
func ( s * NetworkService ) NewReleasePublicIpRangeParams ( id string ) * ReleasePublicIpRangeParams {
p := & ReleasePublicIpRangeParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "id" ] = id
return p
}
// Releases a Public IP range back to the system pool
func ( s * NetworkService ) ReleasePublicIpRange ( p * ReleasePublicIpRangeParams ) ( * ReleasePublicIpRangeResponse , error ) {
resp , err := s . cs . newRequest ( "releasePublicIpRange" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
2019-02-01 14:26:40 -05:00
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
var r ReleasePublicIpRangeResponse
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
return & r , nil
}
type ReleasePublicIpRangeResponse struct {
Displaytext string ` json:"displaytext" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Success bool ` json:"success" `
}
func ( r * ReleasePublicIpRangeResponse ) UnmarshalJSON ( b [ ] byte ) error {
var m map [ string ] interface { }
err := json . Unmarshal ( b , & m )
if err != nil {
return err
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if success , ok := m [ "success" ] . ( string ) ; ok {
m [ "success" ] = success == "true"
b , err = json . Marshal ( m )
if err != nil {
return err
2016-10-07 10:39:28 -04:00
}
}
2019-02-01 14:26:40 -05:00
2019-05-26 05:58:26 -04:00
if ostypeid , ok := m [ "ostypeid" ] . ( float64 ) ; ok {
m [ "ostypeid" ] = strconv . Itoa ( int ( ostypeid ) )
b , err = json . Marshal ( m )
if err != nil {
return err
}
}
2019-02-01 14:26:40 -05:00
type alias ReleasePublicIpRangeResponse
return json . Unmarshal ( b , ( * alias ) ( r ) )
}
type RestartNetworkParams struct {
p map [ string ] interface { }
}
func ( p * RestartNetworkParams ) toURLValues ( ) url . Values {
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "cleanup" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "cleanup" , vv )
}
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
if v , found := p . p [ "makeredundant" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "makeredundant" , vv )
}
return u
}
func ( p * RestartNetworkParams ) SetCleanup ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "cleanup" ] = v
return
}
func ( p * RestartNetworkParams ) SetId ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "id" ] = v
return
}
func ( p * RestartNetworkParams ) SetMakeredundant ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "makeredundant" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new RestartNetworkParams instance,
// as then you are sure you have configured all required params
func ( s * NetworkService ) NewRestartNetworkParams ( id string ) * RestartNetworkParams {
p := & RestartNetworkParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "id" ] = id
return p
}
// Restarts the network; includes 1) restarting network elements - virtual routers, DHCP servers 2) reapplying all public IPs 3) reapplying loadBalancing/portForwarding rules
func ( s * NetworkService ) RestartNetwork ( p * RestartNetworkParams ) ( * RestartNetworkResponse , error ) {
resp , err := s . cs . newRequest ( "restartNetwork" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r RestartNetworkResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
return & r , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type RestartNetworkResponse struct {
Account string ` json:"account" `
Allocated string ` json:"allocated" `
Associatednetworkid string ` json:"associatednetworkid" `
Associatednetworkname string ` json:"associatednetworkname" `
Domain string ` json:"domain" `
Domainid string ` json:"domainid" `
Fordisplay bool ` json:"fordisplay" `
Forvirtualnetwork bool ` json:"forvirtualnetwork" `
Id string ` json:"id" `
Ipaddress string ` json:"ipaddress" `
Isportable bool ` json:"isportable" `
Issourcenat bool ` json:"issourcenat" `
Isstaticnat bool ` json:"isstaticnat" `
Issystem bool ` json:"issystem" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Networkid string ` json:"networkid" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Purpose string ` json:"purpose" `
State string ` json:"state" `
Tags [ ] Tags ` json:"tags" `
Virtualmachinedisplayname string ` json:"virtualmachinedisplayname" `
Virtualmachineid string ` json:"virtualmachineid" `
Virtualmachinename string ` json:"virtualmachinename" `
Vlanid string ` json:"vlanid" `
Vlanname string ` json:"vlanname" `
Vmipaddress string ` json:"vmipaddress" `
Vpcid string ` json:"vpcid" `
Zoneid string ` json:"zoneid" `
Zonename string ` json:"zonename" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type UpdateNetworkParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "changecidr" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "changecidr" , vv )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "customid" ] ; found {
u . Set ( "customid" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "displaynetwork" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "displaynetwork" , vv )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "displaytext" ] ; found {
u . Set ( "displaytext" , v . ( string ) )
}
if v , found := p . p [ "forced" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "forced" , vv )
}
if v , found := p . p [ "guestvmcidr" ] ; found {
u . Set ( "guestvmcidr" , v . ( string ) )
}
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
if v , found := p . p [ "name" ] ; found {
u . Set ( "name" , v . ( string ) )
}
if v , found := p . p [ "networkdomain" ] ; found {
u . Set ( "networkdomain" , v . ( string ) )
}
if v , found := p . p [ "networkofferingid" ] ; found {
u . Set ( "networkofferingid" , v . ( string ) )
}
if v , found := p . p [ "updateinsequence" ] ; found {
vv := strconv . FormatBool ( v . ( bool ) )
u . Set ( "updateinsequence" , vv )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetChangecidr ( v bool ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "changecidr" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetCustomid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "customid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetDisplaynetwork ( v bool ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "displaynetwork" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetDisplaytext ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "displaytext" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetForced ( v bool ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "forced" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetGuestvmcidr ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "guestvmcidr" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetId ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "id" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetName ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
2019-02-01 14:26:40 -05:00
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "name" ] = v
return
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetNetworkdomain ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "networkdomain" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetNetworkofferingid ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "networkofferingid" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkParams ) SetUpdateinsequence ( v bool ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "updateinsequence" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new UpdateNetworkParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewUpdateNetworkParams ( id string ) * UpdateNetworkParams {
p := & UpdateNetworkParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = id
2016-10-07 10:39:28 -04:00
return p
}
2019-02-01 14:26:40 -05:00
// Updates a network
func ( s * NetworkService ) UpdateNetwork ( p * UpdateNetworkParams ) ( * UpdateNetworkResponse , error ) {
resp , err := s . cs . newRequest ( "updateNetwork" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r UpdateNetworkResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
return & r , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type UpdateNetworkResponse struct {
Account string ` json:"account" `
Aclid string ` json:"aclid" `
Acltype string ` json:"acltype" `
Broadcastdomaintype string ` json:"broadcastdomaintype" `
Broadcasturi string ` json:"broadcasturi" `
Canusefordeploy bool ` json:"canusefordeploy" `
Cidr string ` json:"cidr" `
Displaynetwork bool ` json:"displaynetwork" `
Displaytext string ` json:"displaytext" `
Dns1 string ` json:"dns1" `
Dns2 string ` json:"dns2" `
Domain string ` json:"domain" `
Domainid string ` json:"domainid" `
Externalid string ` json:"externalid" `
Gateway string ` json:"gateway" `
Id string ` json:"id" `
Ip6cidr string ` json:"ip6cidr" `
Ip6gateway string ` json:"ip6gateway" `
Isdefault bool ` json:"isdefault" `
Ispersistent bool ` json:"ispersistent" `
Issystem bool ` json:"issystem" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Netmask string ` json:"netmask" `
Networkcidr string ` json:"networkcidr" `
Networkdomain string ` json:"networkdomain" `
Networkofferingavailability string ` json:"networkofferingavailability" `
Networkofferingconservemode bool ` json:"networkofferingconservemode" `
Networkofferingdisplaytext string ` json:"networkofferingdisplaytext" `
Networkofferingid string ` json:"networkofferingid" `
Networkofferingname string ` json:"networkofferingname" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Project string ` json:"project" `
Projectid string ` json:"projectid" `
Redundantrouter bool ` json:"redundantrouter" `
Related string ` json:"related" `
Reservediprange string ` json:"reservediprange" `
Restartrequired bool ` json:"restartrequired" `
Service [ ] UpdateNetworkResponseService ` json:"service" `
Specifyipranges bool ` json:"specifyipranges" `
State string ` json:"state" `
Strechedl2subnet bool ` json:"strechedl2subnet" `
Subdomainaccess bool ` json:"subdomainaccess" `
Tags [ ] Tags ` json:"tags" `
Traffictype string ` json:"traffictype" `
Type string ` json:"type" `
Vlan string ` json:"vlan" `
Vpcid string ` json:"vpcid" `
Zoneid string ` json:"zoneid" `
Zonename string ` json:"zonename" `
Zonesnetworkspans [ ] interface { } ` json:"zonesnetworkspans" `
}
type UpdateNetworkResponseService struct {
Capability [ ] UpdateNetworkResponseServiceCapability ` json:"capability" `
Name string ` json:"name" `
Provider [ ] UpdateNetworkResponseServiceProvider ` json:"provider" `
}
type UpdateNetworkResponseServiceProvider struct {
Canenableindividualservice bool ` json:"canenableindividualservice" `
Destinationphysicalnetworkid string ` json:"destinationphysicalnetworkid" `
Id string ` json:"id" `
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Servicelist [ ] string ` json:"servicelist" `
State string ` json:"state" `
}
type UpdateNetworkResponseServiceCapability struct {
Canchooseservicecapability bool ` json:"canchooseservicecapability" `
Name string ` json:"name" `
Value string ` json:"value" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type UpdateNetworkServiceProviderParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkServiceProviderParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "servicelist" ] ; found {
vv := strings . Join ( v . ( [ ] string ) , "," )
u . Set ( "servicelist" , vv )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "state" ] ; found {
u . Set ( "state" , v . ( string ) )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkServiceProviderParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkServiceProviderParams ) SetServicelist ( v [ ] string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "servicelist" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateNetworkServiceProviderParams ) SetState ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "state" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new UpdateNetworkServiceProviderParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewUpdateNetworkServiceProviderParams ( id string ) * UpdateNetworkServiceProviderParams {
p := & UpdateNetworkServiceProviderParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = id
2016-10-07 10:39:28 -04:00
return p
}
2019-02-01 14:26:40 -05:00
// Updates a network serviceProvider of a physical network
func ( s * NetworkService ) UpdateNetworkServiceProvider ( p * UpdateNetworkServiceProviderParams ) ( * UpdateNetworkServiceProviderResponse , error ) {
resp , err := s . cs . newRequest ( "updateNetworkServiceProvider" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r UpdateNetworkServiceProviderResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type UpdateNetworkServiceProviderResponse struct {
Canenableindividualservice bool ` json:"canenableindividualservice" `
Destinationphysicalnetworkid string ` json:"destinationphysicalnetworkid" `
Id string ` json:"id" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Physicalnetworkid string ` json:"physicalnetworkid" `
Servicelist [ ] string ` json:"servicelist" `
State string ` json:"state" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type UpdatePhysicalNetworkParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * UpdatePhysicalNetworkParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "networkspeed" ] ; found {
u . Set ( "networkspeed" , v . ( string ) )
}
if v , found := p . p [ "state" ] ; found {
u . Set ( "state" , v . ( string ) )
}
if v , found := p . p [ "tags" ] ; found {
vv := strings . Join ( v . ( [ ] string ) , "," )
u . Set ( "tags" , vv )
}
if v , found := p . p [ "vlan" ] ; found {
u . Set ( "vlan" , v . ( string ) )
}
2016-10-07 10:39:28 -04:00
return u
}
2019-02-01 14:26:40 -05:00
func ( p * UpdatePhysicalNetworkParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "id" ] = v
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdatePhysicalNetworkParams ) SetNetworkspeed ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "networkspeed" ] = v
return
}
func ( p * UpdatePhysicalNetworkParams ) SetState ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "state" ] = v
return
}
func ( p * UpdatePhysicalNetworkParams ) SetTags ( v [ ] string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "tags" ] = v
return
}
func ( p * UpdatePhysicalNetworkParams ) SetVlan ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
p . p [ "vlan" ] = v
return
}
// You should always use this function to get a new UpdatePhysicalNetworkParams instance,
2016-10-07 10:39:28 -04:00
// as then you are sure you have configured all required params
2019-02-01 14:26:40 -05:00
func ( s * NetworkService ) NewUpdatePhysicalNetworkParams ( id string ) * UpdatePhysicalNetworkParams {
p := & UpdatePhysicalNetworkParams { }
2016-10-07 10:39:28 -04:00
p . p = make ( map [ string ] interface { } )
p . p [ "id" ] = id
return p
}
2019-02-01 14:26:40 -05:00
// Updates a physical network
func ( s * NetworkService ) UpdatePhysicalNetwork ( p * UpdatePhysicalNetworkParams ) ( * UpdatePhysicalNetworkResponse , error ) {
resp , err := s . cs . newRequest ( "updatePhysicalNetwork" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r UpdatePhysicalNetworkResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
2019-02-01 14:26:40 -05:00
2016-10-07 10:39:28 -04:00
return & r , nil
}
2019-02-01 14:26:40 -05:00
type UpdatePhysicalNetworkResponse struct {
Broadcastdomainrange string ` json:"broadcastdomainrange" `
Domainid string ` json:"domainid" `
Id string ` json:"id" `
Isolationmethods string ` json:"isolationmethods" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Name string ` json:"name" `
Networkspeed string ` json:"networkspeed" `
State string ` json:"state" `
Tags string ` json:"tags" `
Vlan string ` json:"vlan" `
Zoneid string ` json:"zoneid" `
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type UpdateStorageNetworkIpRangeParams struct {
2016-10-07 10:39:28 -04:00
p map [ string ] interface { }
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateStorageNetworkIpRangeParams ) toURLValues ( ) url . Values {
2016-10-07 10:39:28 -04:00
u := url . Values { }
if p . p == nil {
return u
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "endip" ] ; found {
u . Set ( "endip" , v . ( string ) )
}
2016-10-07 10:39:28 -04:00
if v , found := p . p [ "id" ] ; found {
u . Set ( "id" , v . ( string ) )
}
2019-02-01 14:26:40 -05:00
if v , found := p . p [ "netmask" ] ; found {
u . Set ( "netmask" , v . ( string ) )
}
if v , found := p . p [ "startip" ] ; found {
u . Set ( "startip" , v . ( string ) )
}
if v , found := p . p [ "vlan" ] ; found {
vv := strconv . Itoa ( v . ( int ) )
u . Set ( "vlan" , vv )
2016-10-07 10:39:28 -04:00
}
return u
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateStorageNetworkIpRangeParams ) SetEndip ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "endip" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateStorageNetworkIpRangeParams ) SetId ( v string ) {
2016-10-07 10:39:28 -04:00
if p . p == nil {
p . p = make ( map [ string ] interface { } )
}
2019-02-01 14:26:40 -05:00
p . p [ "id" ] = v
2016-10-07 10:39:28 -04:00
return
}
2019-02-01 14:26:40 -05:00
func ( p * UpdateStorageNetworkIpRangeParams ) SetNetmask ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "netmask" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * UpdateStorageNetworkIpRangeParams ) SetStartip ( v string ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "startip" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
func ( p * UpdateStorageNetworkIpRangeParams ) SetVlan ( v int ) {
if p . p == nil {
p . p = make ( map [ string ] interface { } )
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
p . p [ "vlan" ] = v
return
}
2016-10-07 10:39:28 -04:00
2019-02-01 14:26:40 -05:00
// You should always use this function to get a new UpdateStorageNetworkIpRangeParams instance,
// as then you are sure you have configured all required params
func ( s * NetworkService ) NewUpdateStorageNetworkIpRangeParams ( id string ) * UpdateStorageNetworkIpRangeParams {
p := & UpdateStorageNetworkIpRangeParams { }
p . p = make ( map [ string ] interface { } )
p . p [ "id" ] = id
return p
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
// Update a Storage network IP range, only allowed when no IPs in this range have been allocated.
func ( s * NetworkService ) UpdateStorageNetworkIpRange ( p * UpdateStorageNetworkIpRangeParams ) ( * UpdateStorageNetworkIpRangeResponse , error ) {
resp , err := s . cs . newRequest ( "updateStorageNetworkIpRange" , p . toURLValues ( ) )
2016-10-07 10:39:28 -04:00
if err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
var r UpdateStorageNetworkIpRangeResponse
2016-10-07 10:39:28 -04:00
if err := json . Unmarshal ( resp , & r ) ; err != nil {
return nil , err
}
2019-02-01 14:26:40 -05:00
// If we have a async client, we need to wait for the async result
if s . cs . async {
b , err := s . cs . GetAsyncJobResult ( r . JobID , s . cs . timeout )
if err != nil {
if err == AsyncTimeoutErr {
return & r , err
}
return nil , err
}
b , err = getRawValue ( b )
if err != nil {
return nil , err
}
if err := json . Unmarshal ( b , & r ) ; err != nil {
return nil , err
}
}
return & r , nil
2016-10-07 10:39:28 -04:00
}
2019-02-01 14:26:40 -05:00
type UpdateStorageNetworkIpRangeResponse struct {
Endip string ` json:"endip" `
Gateway string ` json:"gateway" `
Id string ` json:"id" `
2019-05-26 05:58:26 -04:00
JobID string ` json:"jobid" `
Jobstatus int ` json:"jobstatus" `
2019-02-01 14:26:40 -05:00
Netmask string ` json:"netmask" `
Networkid string ` json:"networkid" `
Podid string ` json:"podid" `
Startip string ` json:"startip" `
Vlan int ` json:"vlan" `
Zoneid string ` json:"zoneid" `
2016-10-07 10:39:28 -04:00
}