Update `go-cloudstack` dependency

This commit is contained in:
Sander van Harmelen 2016-04-21 16:57:02 +02:00
parent b53d0d29c8
commit cbea101ecf
65 changed files with 1076 additions and 1017 deletions

4
Godeps/Godeps.json generated
View File

@ -1265,8 +1265,8 @@
},
{
"ImportPath": "github.com/xanzy/go-cloudstack/cloudstack",
"Comment": "2.0.0",
"Rev": "6e28220a0503ff25e2c1480791e23d12872140ac"
"Comment": "2.0.0-2-gcfbfb48",
"Rev": "cfbfb481e04c131cb89df1c6141b082f2714bc29"
},
{
"ImportPath": "github.com/xanzy/ssh-agent",

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -1130,12 +1130,18 @@ func (s *AccountService) NewListAccountsParams() *ListAccountsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AccountService) GetAccountID(name string) (string, error) {
func (s *AccountService) GetAccountID(name string, opts ...OptionFunc) (string, error) {
p := &ListAccountsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListAccounts(p)
if err != nil {
return "", err
@ -1160,13 +1166,13 @@ func (s *AccountService) GetAccountID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AccountService) GetAccountByName(name string) (*Account, int, error) {
id, err := s.GetAccountID(name)
func (s *AccountService) GetAccountByName(name string, opts ...OptionFunc) (*Account, int, error) {
id, err := s.GetAccountID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetAccountByID(id)
r, count, err := s.GetAccountByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -1174,12 +1180,18 @@ func (s *AccountService) GetAccountByName(name string) (*Account, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AccountService) GetAccountByID(id string) (*Account, int, error) {
func (s *AccountService) GetAccountByID(id string, opts ...OptionFunc) (*Account, int, error) {
p := &ListAccountsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListAccounts(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1716,28 +1728,24 @@ func (s *AccountService) NewListProjectAccountsParams(projectid string) *ListPro
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AccountService) GetProjectAccountID(keyword string, projectid string) (string, error) {
func (s *AccountService) GetProjectAccountID(keyword string, projectid string, opts ...OptionFunc) (string, error) {
p := &ListProjectAccountsParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
p.p["projectid"] = projectid
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListProjectAccounts(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListProjectAccounts(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -581,12 +581,18 @@ func (s *AddressService) NewListPublicIpAddressesParams() *ListPublicIpAddresses
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AddressService) GetPublicIpAddressByID(id string) (*PublicIpAddress, int, error) {
func (s *AddressService) GetPublicIpAddressByID(id string, opts ...OptionFunc) (*PublicIpAddress, int, error) {
p := &ListPublicIpAddressesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListPublicIpAddresses(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -597,21 +603,6 @@ func (s *AddressService) GetPublicIpAddressByID(id string) (*PublicIpAddress, in
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListPublicIpAddresses(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -427,27 +427,23 @@ func (s *AffinityGroupService) NewListAffinityGroupsParams() *ListAffinityGroups
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AffinityGroupService) GetAffinityGroupID(name string) (string, error) {
func (s *AffinityGroupService) GetAffinityGroupID(name string, opts ...OptionFunc) (string, error) {
p := &ListAffinityGroupsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListAffinityGroups(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListAffinityGroups(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -467,13 +463,13 @@ func (s *AffinityGroupService) GetAffinityGroupID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AffinityGroupService) GetAffinityGroupByName(name string) (*AffinityGroup, int, error) {
id, err := s.GetAffinityGroupID(name)
func (s *AffinityGroupService) GetAffinityGroupByName(name string, opts ...OptionFunc) (*AffinityGroup, int, error) {
id, err := s.GetAffinityGroupID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetAffinityGroupByID(id)
r, count, err := s.GetAffinityGroupByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -481,12 +477,18 @@ func (s *AffinityGroupService) GetAffinityGroupByName(name string) (*AffinityGro
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AffinityGroupService) GetAffinityGroupByID(id string) (*AffinityGroup, int, error) {
func (s *AffinityGroupService) GetAffinityGroupByID(id string, opts ...OptionFunc) (*AffinityGroup, int, error) {
p := &ListAffinityGroupsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListAffinityGroups(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -497,21 +499,6 @@ func (s *AffinityGroupService) GetAffinityGroupByID(id string) (*AffinityGroup,
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListAffinityGroups(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -113,12 +113,18 @@ func (s *AlertService) NewListAlertsParams() *ListAlertsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AlertService) GetAlertID(name string) (string, error) {
func (s *AlertService) GetAlertID(name string, opts ...OptionFunc) (string, error) {
p := &ListAlertsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListAlerts(p)
if err != nil {
return "", err
@ -143,13 +149,13 @@ func (s *AlertService) GetAlertID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AlertService) GetAlertByName(name string) (*Alert, int, error) {
id, err := s.GetAlertID(name)
func (s *AlertService) GetAlertByName(name string, opts ...OptionFunc) (*Alert, int, error) {
id, err := s.GetAlertID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetAlertByID(id)
r, count, err := s.GetAlertByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -157,12 +163,18 @@ func (s *AlertService) GetAlertByName(name string) (*Alert, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AlertService) GetAlertByID(id string) (*Alert, int, error) {
func (s *AlertService) GetAlertByID(id string, opts ...OptionFunc) (*Alert, int, error) {
p := &ListAlertsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListAlerts(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -1134,12 +1134,18 @@ func (s *AutoScaleService) NewListCountersParams() *ListCountersParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetCounterID(name string) (string, error) {
func (s *AutoScaleService) GetCounterID(name string, opts ...OptionFunc) (string, error) {
p := &ListCountersParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListCounters(p)
if err != nil {
return "", err
@ -1164,13 +1170,13 @@ func (s *AutoScaleService) GetCounterID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetCounterByName(name string) (*Counter, int, error) {
id, err := s.GetCounterID(name)
func (s *AutoScaleService) GetCounterByName(name string, opts ...OptionFunc) (*Counter, int, error) {
id, err := s.GetCounterID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetCounterByID(id)
r, count, err := s.GetCounterByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -1178,12 +1184,18 @@ func (s *AutoScaleService) GetCounterByName(name string) (*Counter, int, error)
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetCounterByID(id string) (*Counter, int, error) {
func (s *AutoScaleService) GetCounterByID(id string, opts ...OptionFunc) (*Counter, int, error) {
p := &ListCountersParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListCounters(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1366,12 +1378,18 @@ func (s *AutoScaleService) NewListConditionsParams() *ListConditionsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetConditionByID(id string) (*Condition, int, error) {
func (s *AutoScaleService) GetConditionByID(id string, opts ...OptionFunc) (*Condition, int, error) {
p := &ListConditionsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListConditions(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1570,12 +1588,18 @@ func (s *AutoScaleService) NewListAutoScalePoliciesParams() *ListAutoScalePolici
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetAutoScalePolicyByID(id string) (*AutoScalePolicy, int, error) {
func (s *AutoScaleService) GetAutoScalePolicyByID(id string, opts ...OptionFunc) (*AutoScalePolicy, int, error) {
p := &ListAutoScalePoliciesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListAutoScalePolicies(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1808,12 +1832,18 @@ func (s *AutoScaleService) NewListAutoScaleVmProfilesParams() *ListAutoScaleVmPr
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetAutoScaleVmProfileByID(id string) (*AutoScaleVmProfile, int, error) {
func (s *AutoScaleService) GetAutoScaleVmProfileByID(id string, opts ...OptionFunc) (*AutoScaleVmProfile, int, error) {
p := &ListAutoScaleVmProfilesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListAutoScaleVmProfiles(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1824,21 +1854,6 @@ func (s *AutoScaleService) GetAutoScaleVmProfileByID(id string) (*AutoScaleVmPro
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListAutoScaleVmProfiles(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)
}
@ -2064,12 +2079,18 @@ func (s *AutoScaleService) NewListAutoScaleVmGroupsParams() *ListAutoScaleVmGrou
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetAutoScaleVmGroupByID(id string) (*AutoScaleVmGroup, int, error) {
func (s *AutoScaleService) GetAutoScaleVmGroupByID(id string, opts ...OptionFunc) (*AutoScaleVmGroup, int, error) {
p := &ListAutoScaleVmGroupsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListAutoScaleVmGroups(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -2080,21 +2101,6 @@ func (s *AutoScaleService) GetAutoScaleVmGroupByID(id string) (*AutoScaleVmGroup
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListAutoScaleVmGroups(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -636,12 +636,18 @@ func (s *ClusterService) NewListClustersParams() *ListClustersParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ClusterService) GetClusterID(name string) (string, error) {
func (s *ClusterService) GetClusterID(name string, opts ...OptionFunc) (string, error) {
p := &ListClustersParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListClusters(p)
if err != nil {
return "", err
@ -666,13 +672,13 @@ func (s *ClusterService) GetClusterID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ClusterService) GetClusterByName(name string) (*Cluster, int, error) {
id, err := s.GetClusterID(name)
func (s *ClusterService) GetClusterByName(name string, opts ...OptionFunc) (*Cluster, int, error) {
id, err := s.GetClusterID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetClusterByID(id)
r, count, err := s.GetClusterByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -680,12 +686,18 @@ func (s *ClusterService) GetClusterByName(name string) (*Cluster, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ClusterService) GetClusterByID(id string) (*Cluster, int, error) {
func (s *ClusterService) GetClusterByID(id string, opts ...OptionFunc) (*Cluster, int, error) {
p := &ListClustersParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListClusters(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -562,12 +562,18 @@ func (s *DiskOfferingService) NewListDiskOfferingsParams() *ListDiskOfferingsPar
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *DiskOfferingService) GetDiskOfferingID(name string) (string, error) {
func (s *DiskOfferingService) GetDiskOfferingID(name string, opts ...OptionFunc) (string, error) {
p := &ListDiskOfferingsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListDiskOfferings(p)
if err != nil {
return "", err
@ -592,13 +598,13 @@ func (s *DiskOfferingService) GetDiskOfferingID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *DiskOfferingService) GetDiskOfferingByName(name string) (*DiskOffering, int, error) {
id, err := s.GetDiskOfferingID(name)
func (s *DiskOfferingService) GetDiskOfferingByName(name string, opts ...OptionFunc) (*DiskOffering, int, error) {
id, err := s.GetDiskOfferingID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetDiskOfferingByID(id)
r, count, err := s.GetDiskOfferingByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -606,12 +612,18 @@ func (s *DiskOfferingService) GetDiskOfferingByName(name string) (*DiskOffering,
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *DiskOfferingService) GetDiskOfferingByID(id string) (*DiskOffering, int, error) {
func (s *DiskOfferingService) GetDiskOfferingByID(id string, opts ...OptionFunc) (*DiskOffering, int, error) {
p := &ListDiskOfferingsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListDiskOfferings(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -448,12 +448,18 @@ func (s *DomainService) NewListDomainsParams() *ListDomainsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *DomainService) GetDomainID(name string) (string, error) {
func (s *DomainService) GetDomainID(name string, opts ...OptionFunc) (string, error) {
p := &ListDomainsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListDomains(p)
if err != nil {
return "", err
@ -478,13 +484,13 @@ func (s *DomainService) GetDomainID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *DomainService) GetDomainByName(name string) (*Domain, int, error) {
id, err := s.GetDomainID(name)
func (s *DomainService) GetDomainByName(name string, opts ...OptionFunc) (*Domain, int, error) {
id, err := s.GetDomainID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetDomainByID(id)
r, count, err := s.GetDomainByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -492,12 +498,18 @@ func (s *DomainService) GetDomainByName(name string) (*Domain, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *DomainService) GetDomainByID(id string) (*Domain, int, error) {
func (s *DomainService) GetDomainByID(id string, opts ...OptionFunc) (*Domain, int, error) {
p := &ListDomainsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListDomains(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -687,12 +699,18 @@ func (s *DomainService) NewListDomainChildrenParams() *ListDomainChildrenParams
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *DomainService) GetDomainChildrenID(name string) (string, error) {
func (s *DomainService) GetDomainChildrenID(name string, opts ...OptionFunc) (string, error) {
p := &ListDomainChildrenParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListDomainChildren(p)
if err != nil {
return "", err
@ -717,13 +735,13 @@ func (s *DomainService) GetDomainChildrenID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *DomainService) GetDomainChildrenByName(name string) (*DomainChildren, int, error) {
id, err := s.GetDomainChildrenID(name)
func (s *DomainService) GetDomainChildrenByName(name string, opts ...OptionFunc) (*DomainChildren, int, error) {
id, err := s.GetDomainChildrenID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetDomainChildrenByID(id)
r, count, err := s.GetDomainChildrenByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -731,12 +749,18 @@ func (s *DomainService) GetDomainChildrenByName(name string) (*DomainChildren, i
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *DomainService) GetDomainChildrenByID(id string) (*DomainChildren, int, error) {
func (s *DomainService) GetDomainChildrenByID(id string, opts ...OptionFunc) (*DomainChildren, int, error) {
p := &ListDomainChildrenParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListDomainChildren(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -216,12 +216,18 @@ func (s *EventService) NewListEventsParams() *ListEventsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *EventService) GetEventByID(id string) (*Event, int, error) {
func (s *EventService) GetEventByID(id string, opts ...OptionFunc) (*Event, int, error) {
p := &ListEventsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListEvents(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -232,21 +238,6 @@ func (s *EventService) GetEventByID(id string) (*Event, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListEvents(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -248,12 +248,18 @@ func (s *FirewallService) NewListPortForwardingRulesParams() *ListPortForwarding
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *FirewallService) GetPortForwardingRuleByID(id string) (*PortForwardingRule, int, error) {
func (s *FirewallService) GetPortForwardingRuleByID(id string, opts ...OptionFunc) (*PortForwardingRule, int, error) {
p := &ListPortForwardingRulesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListPortForwardingRules(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -264,21 +270,6 @@ func (s *FirewallService) GetPortForwardingRuleByID(id string) (*PortForwardingR
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListPortForwardingRules(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)
}
@ -1276,12 +1267,18 @@ func (s *FirewallService) NewListFirewallRulesParams() *ListFirewallRulesParams
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *FirewallService) GetFirewallRuleByID(id string) (*FirewallRule, int, error) {
func (s *FirewallService) GetFirewallRuleByID(id string, opts ...OptionFunc) (*FirewallRule, int, error) {
p := &ListFirewallRulesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListFirewallRules(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1292,21 +1289,6 @@ func (s *FirewallService) GetFirewallRuleByID(id string) (*FirewallRule, int, er
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListFirewallRules(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)
}
@ -1945,12 +1927,18 @@ func (s *FirewallService) NewListEgressFirewallRulesParams() *ListEgressFirewall
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *FirewallService) GetEgressFirewallRuleByID(id string) (*EgressFirewallRule, int, error) {
func (s *FirewallService) GetEgressFirewallRuleByID(id string, opts ...OptionFunc) (*EgressFirewallRule, int, error) {
p := &ListEgressFirewallRulesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListEgressFirewallRules(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1961,21 +1949,6 @@ func (s *FirewallService) GetEgressFirewallRuleByID(id string) (*EgressFirewallR
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListEgressFirewallRules(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -113,12 +113,18 @@ func (s *GuestOSService) NewListOsTypesParams() *ListOsTypesParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *GuestOSService) GetOsTypeByID(id string) (*OsType, int, error) {
func (s *GuestOSService) GetOsTypeByID(id string, opts ...OptionFunc) (*OsType, int, error) {
p := &ListOsTypesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListOsTypes(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -243,12 +249,18 @@ func (s *GuestOSService) NewListOsCategoriesParams() *ListOsCategoriesParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *GuestOSService) GetOsCategoryID(name string) (string, error) {
func (s *GuestOSService) GetOsCategoryID(name string, opts ...OptionFunc) (string, error) {
p := &ListOsCategoriesParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListOsCategories(p)
if err != nil {
return "", err
@ -273,13 +285,13 @@ func (s *GuestOSService) GetOsCategoryID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *GuestOSService) GetOsCategoryByName(name string) (*OsCategory, int, error) {
id, err := s.GetOsCategoryID(name)
func (s *GuestOSService) GetOsCategoryByName(name string, opts ...OptionFunc) (*OsCategory, int, error) {
id, err := s.GetOsCategoryID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetOsCategoryByID(id)
r, count, err := s.GetOsCategoryByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -287,12 +299,18 @@ func (s *GuestOSService) GetOsCategoryByName(name string) (*OsCategory, int, err
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *GuestOSService) GetOsCategoryByID(id string) (*OsCategory, int, error) {
func (s *GuestOSService) GetOsCategoryByID(id string, opts ...OptionFunc) (*OsCategory, int, error) {
p := &ListOsCategoriesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListOsCategories(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -687,12 +705,18 @@ func (s *GuestOSService) NewListGuestOsMappingParams() *ListGuestOsMappingParams
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *GuestOSService) GetGuestOsMappingByID(id string) (*GuestOsMapping, int, error) {
func (s *GuestOSService) GetGuestOsMappingByID(id string, opts ...OptionFunc) (*GuestOsMapping, int, error) {
p := &ListGuestOsMappingParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListGuestOsMapping(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -1037,12 +1037,18 @@ func (s *HostService) NewListHostsParams() *ListHostsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *HostService) GetHostID(name string) (string, error) {
func (s *HostService) GetHostID(name string, opts ...OptionFunc) (string, error) {
p := &ListHostsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListHosts(p)
if err != nil {
return "", err
@ -1067,13 +1073,13 @@ func (s *HostService) GetHostID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *HostService) GetHostByName(name string) (*Host, int, error) {
id, err := s.GetHostID(name)
func (s *HostService) GetHostByName(name string, opts ...OptionFunc) (*Host, int, error) {
id, err := s.GetHostID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetHostByID(id)
r, count, err := s.GetHostByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -1081,12 +1087,18 @@ func (s *HostService) GetHostByName(name string) (*Host, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *HostService) GetHostByID(id string) (*Host, int, error) {
func (s *HostService) GetHostByID(id string, opts ...OptionFunc) (*Host, int, error) {
p := &ListHostsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListHosts(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1243,12 +1255,18 @@ func (s *HostService) NewListHostTagsParams() *ListHostTagsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *HostService) GetHostTagID(keyword string) (string, error) {
func (s *HostService) GetHostTagID(keyword string, opts ...OptionFunc) (string, error) {
p := &ListHostTagsParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListHostTags(p)
if err != nil {
return "", err

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -236,12 +236,18 @@ func (s *HypervisorService) NewListHypervisorCapabilitiesParams() *ListHyperviso
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *HypervisorService) GetHypervisorCapabilityByID(id string) (*HypervisorCapability, int, error) {
func (s *HypervisorService) GetHypervisorCapabilityByID(id string, opts ...OptionFunc) (*HypervisorCapability, int, error) {
p := &ListHypervisorCapabilitiesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListHypervisorCapabilities(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -754,7 +754,7 @@ func (s *ISOService) NewListIsosParams() *ListIsosParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string) (string, error) {
func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string, opts ...OptionFunc) (string, error) {
p := &ListIsosParams{}
p.p = make(map[string]interface{})
@ -762,21 +762,17 @@ func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string) (str
p.p["isofilter"] = isofilter
p.p["zoneid"] = zoneid
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListIsos(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListIsos(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -796,13 +792,13 @@ func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string) (str
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoByName(name string, isofilter string, zoneid string) (*Iso, int, error) {
id, err := s.GetIsoID(name, isofilter, zoneid)
func (s *ISOService) GetIsoByName(name string, isofilter string, zoneid string, opts ...OptionFunc) (*Iso, int, error) {
id, err := s.GetIsoID(name, isofilter, zoneid, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetIsoByID(id)
r, count, err := s.GetIsoByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -810,12 +806,18 @@ func (s *ISOService) GetIsoByName(name string, isofilter string, zoneid string)
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoByID(id string) (*Iso, int, error) {
func (s *ISOService) GetIsoByID(id string, opts ...OptionFunc) (*Iso, int, error) {
p := &ListIsosParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListIsos(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -826,21 +828,6 @@ func (s *ISOService) GetIsoByID(id string) (*Iso, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListIsos(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)
}
@ -1779,13 +1766,19 @@ func (s *ISOService) NewListIsoPermissionsParams(id string) *ListIsoPermissionsP
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoPermissionByID(id string) (*IsoPermission, int, error) {
func (s *ISOService) GetIsoPermissionByID(id string, opts ...OptionFunc) (*IsoPermission, int, error) {
p := &ListIsoPermissionsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListIsoPermissions(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -419,12 +419,18 @@ func (s *ImageStoreService) NewListImageStoresParams() *ListImageStoresParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ImageStoreService) GetImageStoreID(name string) (string, error) {
func (s *ImageStoreService) GetImageStoreID(name string, opts ...OptionFunc) (string, error) {
p := &ListImageStoresParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListImageStores(p)
if err != nil {
return "", err
@ -449,13 +455,13 @@ func (s *ImageStoreService) GetImageStoreID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ImageStoreService) GetImageStoreByName(name string) (*ImageStore, int, error) {
id, err := s.GetImageStoreID(name)
func (s *ImageStoreService) GetImageStoreByName(name string, opts ...OptionFunc) (*ImageStore, int, error) {
id, err := s.GetImageStoreID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetImageStoreByID(id)
r, count, err := s.GetImageStoreByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -463,12 +469,18 @@ func (s *ImageStoreService) GetImageStoreByName(name string) (*ImageStore, int,
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ImageStoreService) GetImageStoreByID(id string) (*ImageStore, int, error) {
func (s *ImageStoreService) GetImageStoreByID(id string, opts ...OptionFunc) (*ImageStore, int, error) {
p := &ListImageStoresParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListImageStores(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -789,12 +801,18 @@ func (s *ImageStoreService) NewListSecondaryStagingStoresParams() *ListSecondary
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ImageStoreService) GetSecondaryStagingStoreID(name string) (string, error) {
func (s *ImageStoreService) GetSecondaryStagingStoreID(name string, opts ...OptionFunc) (string, error) {
p := &ListSecondaryStagingStoresParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListSecondaryStagingStores(p)
if err != nil {
return "", err
@ -819,13 +837,13 @@ func (s *ImageStoreService) GetSecondaryStagingStoreID(name string) (string, err
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ImageStoreService) GetSecondaryStagingStoreByName(name string) (*SecondaryStagingStore, int, error) {
id, err := s.GetSecondaryStagingStoreID(name)
func (s *ImageStoreService) GetSecondaryStagingStoreByName(name string, opts ...OptionFunc) (*SecondaryStagingStore, int, error) {
id, err := s.GetSecondaryStagingStoreID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetSecondaryStagingStoreByID(id)
r, count, err := s.GetSecondaryStagingStoreByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -833,12 +851,18 @@ func (s *ImageStoreService) GetSecondaryStagingStoreByName(name string) (*Second
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ImageStoreService) GetSecondaryStagingStoreByID(id string) (*SecondaryStagingStore, int, error) {
func (s *ImageStoreService) GetSecondaryStagingStoreByID(id string, opts ...OptionFunc) (*SecondaryStagingStore, int, error) {
p := &ListSecondaryStagingStoresParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListSecondaryStagingStores(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -273,12 +273,18 @@ func (s *InternalLBService) NewListInternalLoadBalancerElementsParams() *ListInt
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *InternalLBService) GetInternalLoadBalancerElementByID(id string) (*InternalLoadBalancerElement, int, error) {
func (s *InternalLBService) GetInternalLoadBalancerElementByID(id string, opts ...OptionFunc) (*InternalLoadBalancerElement, int, error) {
p := &ListInternalLoadBalancerElementsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListInternalLoadBalancerElements(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -825,27 +831,23 @@ func (s *InternalLBService) NewListInternalLoadBalancerVMsParams() *ListInternal
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *InternalLBService) GetInternalLoadBalancerVMID(name string) (string, error) {
func (s *InternalLBService) GetInternalLoadBalancerVMID(name string, opts ...OptionFunc) (string, error) {
p := &ListInternalLoadBalancerVMsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListInternalLoadBalancerVMs(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListInternalLoadBalancerVMs(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -865,13 +867,13 @@ func (s *InternalLBService) GetInternalLoadBalancerVMID(name string) (string, er
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *InternalLBService) GetInternalLoadBalancerVMByName(name string) (*InternalLoadBalancerVM, int, error) {
id, err := s.GetInternalLoadBalancerVMID(name)
func (s *InternalLBService) GetInternalLoadBalancerVMByName(name string, opts ...OptionFunc) (*InternalLoadBalancerVM, int, error) {
id, err := s.GetInternalLoadBalancerVMID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetInternalLoadBalancerVMByID(id)
r, count, err := s.GetInternalLoadBalancerVMByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -879,12 +881,18 @@ func (s *InternalLBService) GetInternalLoadBalancerVMByName(name string) (*Inter
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *InternalLBService) GetInternalLoadBalancerVMByID(id string) (*InternalLoadBalancerVM, int, error) {
func (s *InternalLBService) GetInternalLoadBalancerVMByID(id string, opts ...OptionFunc) (*InternalLoadBalancerVM, int, error) {
p := &ListInternalLoadBalancerVMsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListInternalLoadBalancerVMs(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -895,21 +903,6 @@ func (s *InternalLBService) GetInternalLoadBalancerVMByID(id string) (*InternalL
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListInternalLoadBalancerVMs(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -1067,27 +1067,23 @@ func (s *LoadBalancerService) NewListLoadBalancerRulesParams() *ListLoadBalancer
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerRuleID(name string) (string, error) {
func (s *LoadBalancerService) GetLoadBalancerRuleID(name string, opts ...OptionFunc) (string, error) {
p := &ListLoadBalancerRulesParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListLoadBalancerRules(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListLoadBalancerRules(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -1107,13 +1103,13 @@ func (s *LoadBalancerService) GetLoadBalancerRuleID(name string) (string, error)
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerRuleByName(name string) (*LoadBalancerRule, int, error) {
id, err := s.GetLoadBalancerRuleID(name)
func (s *LoadBalancerService) GetLoadBalancerRuleByName(name string, opts ...OptionFunc) (*LoadBalancerRule, int, error) {
id, err := s.GetLoadBalancerRuleID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetLoadBalancerRuleByID(id)
r, count, err := s.GetLoadBalancerRuleByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -1121,12 +1117,18 @@ func (s *LoadBalancerService) GetLoadBalancerRuleByName(name string) (*LoadBalan
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerRuleByID(id string) (*LoadBalancerRule, int, error) {
func (s *LoadBalancerService) GetLoadBalancerRuleByID(id string, opts ...OptionFunc) (*LoadBalancerRule, int, error) {
p := &ListLoadBalancerRulesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListLoadBalancerRules(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1137,21 +1139,6 @@ func (s *LoadBalancerService) GetLoadBalancerRuleByID(id string) (*LoadBalancerR
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListLoadBalancerRules(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)
}
@ -1305,12 +1292,18 @@ func (s *LoadBalancerService) NewListLBStickinessPoliciesParams() *ListLBStickin
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLBStickinessPolicyByID(id string) (*LBStickinessPolicy, int, error) {
func (s *LoadBalancerService) GetLBStickinessPolicyByID(id string, opts ...OptionFunc) (*LBStickinessPolicy, int, error) {
p := &ListLBStickinessPoliciesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListLBStickinessPolicies(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1460,12 +1453,18 @@ func (s *LoadBalancerService) NewListLBHealthCheckPoliciesParams() *ListLBHealth
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLBHealthCheckPolicyByID(id string) (*LBHealthCheckPolicy, int, error) {
func (s *LoadBalancerService) GetLBHealthCheckPolicyByID(id string, opts ...OptionFunc) (*LBHealthCheckPolicy, int, error) {
p := &ListLBHealthCheckPoliciesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListLBHealthCheckPolicies(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1960,13 +1959,19 @@ func (s *LoadBalancerService) NewListLoadBalancerRuleInstancesParams(id string)
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerRuleInstanceByID(id string) (*LoadBalancerRuleInstance, int, error) {
func (s *LoadBalancerService) GetLoadBalancerRuleInstanceByID(id string, opts ...OptionFunc) (*LoadBalancerRuleInstance, int, error) {
p := &ListLoadBalancerRuleInstancesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListLoadBalancerRuleInstances(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -3656,27 +3661,23 @@ func (s *LoadBalancerService) NewListGlobalLoadBalancerRulesParams() *ListGlobal
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetGlobalLoadBalancerRuleID(keyword string) (string, error) {
func (s *LoadBalancerService) GetGlobalLoadBalancerRuleID(keyword string, opts ...OptionFunc) (string, error) {
p := &ListGlobalLoadBalancerRulesParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListGlobalLoadBalancerRules(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListGlobalLoadBalancerRules(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l)
}
@ -3696,13 +3697,13 @@ func (s *LoadBalancerService) GetGlobalLoadBalancerRuleID(keyword string) (strin
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetGlobalLoadBalancerRuleByName(name string) (*GlobalLoadBalancerRule, int, error) {
id, err := s.GetGlobalLoadBalancerRuleID(name)
func (s *LoadBalancerService) GetGlobalLoadBalancerRuleByName(name string, opts ...OptionFunc) (*GlobalLoadBalancerRule, int, error) {
id, err := s.GetGlobalLoadBalancerRuleID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetGlobalLoadBalancerRuleByID(id)
r, count, err := s.GetGlobalLoadBalancerRuleByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -3710,12 +3711,18 @@ func (s *LoadBalancerService) GetGlobalLoadBalancerRuleByName(name string) (*Glo
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetGlobalLoadBalancerRuleByID(id string) (*GlobalLoadBalancerRule, int, error) {
func (s *LoadBalancerService) GetGlobalLoadBalancerRuleByID(id string, opts ...OptionFunc) (*GlobalLoadBalancerRule, int, error) {
p := &ListGlobalLoadBalancerRulesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListGlobalLoadBalancerRules(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -3726,21 +3733,6 @@ func (s *LoadBalancerService) GetGlobalLoadBalancerRuleByID(id string) (*GlobalL
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListGlobalLoadBalancerRules(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)
}
@ -4416,27 +4408,23 @@ func (s *LoadBalancerService) NewListLoadBalancersParams() *ListLoadBalancersPar
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerID(name string) (string, error) {
func (s *LoadBalancerService) GetLoadBalancerID(name string, opts ...OptionFunc) (string, error) {
p := &ListLoadBalancersParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListLoadBalancers(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListLoadBalancers(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -4456,13 +4444,13 @@ func (s *LoadBalancerService) GetLoadBalancerID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerByName(name string) (*LoadBalancer, int, error) {
id, err := s.GetLoadBalancerID(name)
func (s *LoadBalancerService) GetLoadBalancerByName(name string, opts ...OptionFunc) (*LoadBalancer, int, error) {
id, err := s.GetLoadBalancerID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetLoadBalancerByID(id)
r, count, err := s.GetLoadBalancerByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -4470,12 +4458,18 @@ func (s *LoadBalancerService) GetLoadBalancerByName(name string) (*LoadBalancer,
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerByID(id string) (*LoadBalancer, int, error) {
func (s *LoadBalancerService) GetLoadBalancerByID(id string, opts ...OptionFunc) (*LoadBalancer, int, error) {
p := &ListLoadBalancersParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListLoadBalancers(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -4486,21 +4480,6 @@ func (s *LoadBalancerService) GetLoadBalancerByID(id string) (*LoadBalancer, int
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListLoadBalancers(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -481,12 +481,18 @@ func (s *NATService) NewListIpForwardingRulesParams() *ListIpForwardingRulesPara
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NATService) GetIpForwardingRuleByID(id string) (*IpForwardingRule, int, error) {
func (s *NATService) GetIpForwardingRuleByID(id string, opts ...OptionFunc) (*IpForwardingRule, int, error) {
p := &ListIpForwardingRulesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListIpForwardingRules(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -497,21 +503,6 @@ func (s *NATService) GetIpForwardingRuleByID(id string) (*IpForwardingRule, int,
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListIpForwardingRules(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -744,12 +744,18 @@ func (s *NetworkACLService) NewListNetworkACLsParams() *ListNetworkACLsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkACLService) GetNetworkACLByID(id string) (*NetworkACL, int, error) {
func (s *NetworkACLService) GetNetworkACLByID(id string, opts ...OptionFunc) (*NetworkACL, int, error) {
p := &ListNetworkACLsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListNetworkACLs(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -760,21 +766,6 @@ func (s *NetworkACLService) GetNetworkACLByID(id string) (*NetworkACL, int, erro
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListNetworkACLs(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)
}
@ -1267,27 +1258,23 @@ func (s *NetworkACLService) NewListNetworkACLListsParams() *ListNetworkACLListsP
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkACLService) GetNetworkACLListID(name string) (string, error) {
func (s *NetworkACLService) GetNetworkACLListID(name string, opts ...OptionFunc) (string, error) {
p := &ListNetworkACLListsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListNetworkACLLists(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListNetworkACLLists(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -1307,13 +1294,13 @@ func (s *NetworkACLService) GetNetworkACLListID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkACLService) GetNetworkACLListByName(name string) (*NetworkACLList, int, error) {
id, err := s.GetNetworkACLListID(name)
func (s *NetworkACLService) GetNetworkACLListByName(name string, opts ...OptionFunc) (*NetworkACLList, int, error) {
id, err := s.GetNetworkACLListID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetNetworkACLListByID(id)
r, count, err := s.GetNetworkACLListByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -1321,12 +1308,18 @@ func (s *NetworkACLService) GetNetworkACLListByName(name string) (*NetworkACLLis
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkACLService) GetNetworkACLListByID(id string) (*NetworkACLList, int, error) {
func (s *NetworkACLService) GetNetworkACLListByID(id string, opts ...OptionFunc) (*NetworkACLList, int, error) {
p := &ListNetworkACLListsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListNetworkACLLists(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1337,21 +1330,6 @@ func (s *NetworkACLService) GetNetworkACLListByID(id string) (*NetworkACLList, i
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListNetworkACLLists(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -808,12 +808,18 @@ func (s *NetworkOfferingService) NewListNetworkOfferingsParams() *ListNetworkOff
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkOfferingService) GetNetworkOfferingID(name string) (string, error) {
func (s *NetworkOfferingService) GetNetworkOfferingID(name string, opts ...OptionFunc) (string, error) {
p := &ListNetworkOfferingsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListNetworkOfferings(p)
if err != nil {
return "", err
@ -838,13 +844,13 @@ func (s *NetworkOfferingService) GetNetworkOfferingID(name string) (string, erro
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkOfferingService) GetNetworkOfferingByName(name string) (*NetworkOffering, int, error) {
id, err := s.GetNetworkOfferingID(name)
func (s *NetworkOfferingService) GetNetworkOfferingByName(name string, opts ...OptionFunc) (*NetworkOffering, int, error) {
id, err := s.GetNetworkOfferingID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetNetworkOfferingByID(id)
r, count, err := s.GetNetworkOfferingByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -852,12 +858,18 @@ func (s *NetworkOfferingService) GetNetworkOfferingByName(name string) (*Network
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkOfferingService) GetNetworkOfferingByID(id string) (*NetworkOffering, int, error) {
func (s *NetworkOfferingService) GetNetworkOfferingByID(id string, opts ...OptionFunc) (*NetworkOffering, int, error) {
p := &ListNetworkOfferingsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListNetworkOfferings(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -935,27 +935,23 @@ func (s *NetworkService) NewListNetworksParams() *ListNetworksParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNetworkID(keyword string) (string, error) {
func (s *NetworkService) GetNetworkID(keyword string, opts ...OptionFunc) (string, error) {
p := &ListNetworksParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListNetworks(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListNetworks(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l)
}
@ -975,13 +971,13 @@ func (s *NetworkService) GetNetworkID(keyword string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNetworkByName(name string) (*Network, int, error) {
id, err := s.GetNetworkID(name)
func (s *NetworkService) GetNetworkByName(name string, opts ...OptionFunc) (*Network, int, error) {
id, err := s.GetNetworkID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetNetworkByID(id)
r, count, err := s.GetNetworkByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -989,12 +985,18 @@ func (s *NetworkService) GetNetworkByName(name string) (*Network, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNetworkByID(id string) (*Network, int, error) {
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 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(
@ -1005,21 +1007,6 @@ func (s *NetworkService) GetNetworkByID(id string) (*Network, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
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)
}
return nil, -1, err
}
}
if l.Count == 0 {
return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
}
@ -1801,12 +1788,18 @@ func (s *NetworkService) NewListPhysicalNetworksParams() *ListPhysicalNetworksPa
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetPhysicalNetworkID(name string) (string, error) {
func (s *NetworkService) GetPhysicalNetworkID(name string, opts ...OptionFunc) (string, error) {
p := &ListPhysicalNetworksParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListPhysicalNetworks(p)
if err != nil {
return "", err
@ -1831,13 +1824,13 @@ func (s *NetworkService) GetPhysicalNetworkID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetPhysicalNetworkByName(name string) (*PhysicalNetwork, int, error) {
id, err := s.GetPhysicalNetworkID(name)
func (s *NetworkService) GetPhysicalNetworkByName(name string, opts ...OptionFunc) (*PhysicalNetwork, int, error) {
id, err := s.GetPhysicalNetworkID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetPhysicalNetworkByID(id)
r, count, err := s.GetPhysicalNetworkByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -1845,12 +1838,18 @@ func (s *NetworkService) GetPhysicalNetworkByName(name string) (*PhysicalNetwork
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetPhysicalNetworkByID(id string) (*PhysicalNetwork, int, error) {
func (s *NetworkService) GetPhysicalNetworkByID(id string, opts ...OptionFunc) (*PhysicalNetwork, int, error) {
p := &ListPhysicalNetworksParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListPhysicalNetworks(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -2410,12 +2409,18 @@ func (s *NetworkService) NewListNetworkServiceProvidersParams() *ListNetworkServ
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNetworkServiceProviderID(name string) (string, error) {
func (s *NetworkService) GetNetworkServiceProviderID(name string, opts ...OptionFunc) (string, error) {
p := &ListNetworkServiceProvidersParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListNetworkServiceProviders(p)
if err != nil {
return "", err
@ -2862,12 +2867,18 @@ func (s *NetworkService) NewListStorageNetworkIpRangeParams() *ListStorageNetwor
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetStorageNetworkIpRangeByID(id string) (*StorageNetworkIpRange, int, error) {
func (s *NetworkService) GetStorageNetworkIpRangeByID(id string, opts ...OptionFunc) (*StorageNetworkIpRange, int, error) {
p := &ListStorageNetworkIpRangeParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListStorageNetworkIpRange(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -3111,13 +3122,19 @@ func (s *NetworkService) NewListPaloAltoFirewallNetworksParams(lbdeviceid string
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetPaloAltoFirewallNetworkID(keyword string, lbdeviceid string) (string, error) {
func (s *NetworkService) GetPaloAltoFirewallNetworkID(keyword string, lbdeviceid string, opts ...OptionFunc) (string, error) {
p := &ListPaloAltoFirewallNetworksParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
p.p["lbdeviceid"] = lbdeviceid
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListPaloAltoFirewallNetworks(p)
if err != nil {
return "", err
@ -3306,13 +3323,19 @@ func (s *NetworkService) NewListNetscalerLoadBalancerNetworksParams(lbdeviceid s
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNetscalerLoadBalancerNetworkID(keyword string, lbdeviceid string) (string, error) {
func (s *NetworkService) GetNetscalerLoadBalancerNetworkID(keyword string, lbdeviceid string, opts ...OptionFunc) (string, error) {
p := &ListNetscalerLoadBalancerNetworksParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
p.p["lbdeviceid"] = lbdeviceid
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListNetscalerLoadBalancerNetworks(p)
if err != nil {
return "", err
@ -3501,13 +3524,19 @@ func (s *NetworkService) NewListNiciraNvpDeviceNetworksParams(nvpdeviceid string
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNiciraNvpDeviceNetworkID(keyword string, nvpdeviceid string) (string, error) {
func (s *NetworkService) GetNiciraNvpDeviceNetworkID(keyword string, nvpdeviceid string, opts ...OptionFunc) (string, error) {
p := &ListNiciraNvpDeviceNetworksParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
p.p["nvpdeviceid"] = nvpdeviceid
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListNiciraNvpDeviceNetworks(p)
if err != nil {
return "", err
@ -3935,12 +3964,18 @@ func (s *NetworkService) NewListOpenDaylightControllersParams() *ListOpenDayligh
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetOpenDaylightControllerByID(id string) (*OpenDaylightController, int, error) {
func (s *NetworkService) GetOpenDaylightControllerByID(id string, opts ...OptionFunc) (*OpenDaylightController, int, error) {
p := &ListOpenDaylightControllersParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range 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(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -205,12 +205,18 @@ func (s *OvsElementService) NewListOvsElementsParams() *ListOvsElementsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *OvsElementService) GetOvsElementByID(id string) (*OvsElement, int, error) {
func (s *OvsElementService) GetOvsElementByID(id string, opts ...OptionFunc) (*OvsElement, int, error) {
p := &ListOvsElementsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListOvsElements(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -463,12 +463,18 @@ func (s *PodService) NewListPodsParams() *ListPodsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *PodService) GetPodID(name string) (string, error) {
func (s *PodService) GetPodID(name string, opts ...OptionFunc) (string, error) {
p := &ListPodsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListPods(p)
if err != nil {
return "", err
@ -493,13 +499,13 @@ func (s *PodService) GetPodID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *PodService) GetPodByName(name string) (*Pod, int, error) {
id, err := s.GetPodID(name)
func (s *PodService) GetPodByName(name string, opts ...OptionFunc) (*Pod, int, error) {
id, err := s.GetPodID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetPodByID(id)
r, count, err := s.GetPodByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -507,12 +513,18 @@ func (s *PodService) GetPodByName(name string) (*Pod, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *PodService) GetPodByID(id string) (*Pod, int, error) {
func (s *PodService) GetPodByID(id string, opts ...OptionFunc) (*Pod, int, error) {
p := &ListPodsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListPods(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -168,12 +168,18 @@ func (s *PoolService) NewListStoragePoolsParams() *ListStoragePoolsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *PoolService) GetStoragePoolID(name string) (string, error) {
func (s *PoolService) GetStoragePoolID(name string, opts ...OptionFunc) (string, error) {
p := &ListStoragePoolsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListStoragePools(p)
if err != nil {
return "", err
@ -198,13 +204,13 @@ func (s *PoolService) GetStoragePoolID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *PoolService) GetStoragePoolByName(name string) (*StoragePool, int, error) {
id, err := s.GetStoragePoolID(name)
func (s *PoolService) GetStoragePoolByName(name string, opts ...OptionFunc) (*StoragePool, int, error) {
id, err := s.GetStoragePoolID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetStoragePoolByID(id)
r, count, err := s.GetStoragePoolByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -212,12 +218,18 @@ func (s *PoolService) GetStoragePoolByName(name string) (*StoragePool, int, erro
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *PoolService) GetStoragePoolByID(id string) (*StoragePool, int, error) {
func (s *PoolService) GetStoragePoolByID(id string, opts ...OptionFunc) (*StoragePool, int, error) {
p := &ListStoragePoolsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListStoragePools(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -319,12 +319,18 @@ func (s *PortableIPService) NewListPortableIpRangesParams() *ListPortableIpRange
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *PortableIPService) GetPortableIpRangeByID(id string) (*PortableIpRange, int, error) {
func (s *PortableIPService) GetPortableIpRangeByID(id string, opts ...OptionFunc) (*PortableIpRange, int, error) {
p := &ListPortableIpRangesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListPortableIpRanges(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -805,12 +805,18 @@ func (s *ProjectService) NewListProjectsParams() *ListProjectsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ProjectService) GetProjectID(name string) (string, error) {
func (s *ProjectService) GetProjectID(name string, opts ...OptionFunc) (string, error) {
p := &ListProjectsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListProjects(p)
if err != nil {
return "", err
@ -835,13 +841,13 @@ func (s *ProjectService) GetProjectID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ProjectService) GetProjectByName(name string) (*Project, int, error) {
id, err := s.GetProjectID(name)
func (s *ProjectService) GetProjectByName(name string, opts ...OptionFunc) (*Project, int, error) {
id, err := s.GetProjectID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetProjectByID(id)
r, count, err := s.GetProjectByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -849,12 +855,18 @@ func (s *ProjectService) GetProjectByName(name string) (*Project, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ProjectService) GetProjectByID(id string) (*Project, int, error) {
func (s *ProjectService) GetProjectByID(id string, opts ...OptionFunc) (*Project, int, error) {
p := &ListProjectsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListProjects(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1098,12 +1110,18 @@ func (s *ProjectService) NewListProjectInvitationsParams() *ListProjectInvitatio
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ProjectService) GetProjectInvitationByID(id string) (*ProjectInvitation, int, error) {
func (s *ProjectService) GetProjectInvitationByID(id string, opts ...OptionFunc) (*ProjectInvitation, int, error) {
p := &ListProjectInvitationsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListProjectInvitations(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1114,21 +1132,6 @@ func (s *ProjectService) GetProjectInvitationByID(id string) (*ProjectInvitation
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListProjectInvitations(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -80,12 +80,18 @@ func (s *ResourcetagsService) NewListStorageTagsParams() *ListStorageTagsParams
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ResourcetagsService) GetStorageTagID(keyword string) (string, error) {
func (s *ResourcetagsService) GetStorageTagID(keyword string, opts ...OptionFunc) (string, error) {
p := &ListStorageTagsParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListStorageTags(p)
if err != nil {
return "", err

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -952,27 +952,23 @@ func (s *RouterService) NewListRoutersParams() *ListRoutersParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *RouterService) GetRouterID(name string) (string, error) {
func (s *RouterService) GetRouterID(name string, opts ...OptionFunc) (string, error) {
p := &ListRoutersParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListRouters(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListRouters(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -992,13 +988,13 @@ func (s *RouterService) GetRouterID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *RouterService) GetRouterByName(name string) (*Router, int, error) {
id, err := s.GetRouterID(name)
func (s *RouterService) GetRouterByName(name string, opts ...OptionFunc) (*Router, int, error) {
id, err := s.GetRouterID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetRouterByID(id)
r, count, err := s.GetRouterByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -1006,12 +1002,18 @@ func (s *RouterService) GetRouterByName(name string) (*Router, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *RouterService) GetRouterByID(id string) (*Router, int, error) {
func (s *RouterService) GetRouterByID(id string, opts ...OptionFunc) (*Router, int, error) {
p := &ListRoutersParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListRouters(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1022,21 +1024,6 @@ func (s *RouterService) GetRouterByID(id string) (*Router, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListRouters(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)
}
@ -1227,12 +1214,18 @@ func (s *RouterService) NewListVirtualRouterElementsParams() *ListVirtualRouterE
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *RouterService) GetVirtualRouterElementByID(id string) (*VirtualRouterElement, int, error) {
func (s *RouterService) GetVirtualRouterElementByID(id string, opts ...OptionFunc) (*VirtualRouterElement, int, error) {
p := &ListVirtualRouterElementsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListVirtualRouterElements(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -1017,27 +1017,23 @@ func (s *SecurityGroupService) NewListSecurityGroupsParams() *ListSecurityGroups
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SecurityGroupService) GetSecurityGroupID(keyword string) (string, error) {
func (s *SecurityGroupService) GetSecurityGroupID(keyword string, opts ...OptionFunc) (string, error) {
p := &ListSecurityGroupsParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListSecurityGroups(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListSecurityGroups(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l)
}
@ -1057,13 +1053,13 @@ func (s *SecurityGroupService) GetSecurityGroupID(keyword string) (string, error
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SecurityGroupService) GetSecurityGroupByName(name string) (*SecurityGroup, int, error) {
id, err := s.GetSecurityGroupID(name)
func (s *SecurityGroupService) GetSecurityGroupByName(name string, opts ...OptionFunc) (*SecurityGroup, int, error) {
id, err := s.GetSecurityGroupID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetSecurityGroupByID(id)
r, count, err := s.GetSecurityGroupByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -1071,12 +1067,18 @@ func (s *SecurityGroupService) GetSecurityGroupByName(name string) (*SecurityGro
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SecurityGroupService) GetSecurityGroupByID(id string) (*SecurityGroup, int, error) {
func (s *SecurityGroupService) GetSecurityGroupByID(id string, opts ...OptionFunc) (*SecurityGroup, int, error) {
p := &ListSecurityGroupsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListSecurityGroups(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1087,21 +1089,6 @@ func (s *SecurityGroupService) GetSecurityGroupByID(id string) (*SecurityGroup,
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListSecurityGroups(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -717,12 +717,18 @@ func (s *ServiceOfferingService) NewListServiceOfferingsParams() *ListServiceOff
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ServiceOfferingService) GetServiceOfferingID(name string) (string, error) {
func (s *ServiceOfferingService) GetServiceOfferingID(name string, opts ...OptionFunc) (string, error) {
p := &ListServiceOfferingsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListServiceOfferings(p)
if err != nil {
return "", err
@ -747,13 +753,13 @@ func (s *ServiceOfferingService) GetServiceOfferingID(name string) (string, erro
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ServiceOfferingService) GetServiceOfferingByName(name string) (*ServiceOffering, int, error) {
id, err := s.GetServiceOfferingID(name)
func (s *ServiceOfferingService) GetServiceOfferingByName(name string, opts ...OptionFunc) (*ServiceOffering, int, error) {
id, err := s.GetServiceOfferingID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetServiceOfferingByID(id)
r, count, err := s.GetServiceOfferingByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -761,12 +767,18 @@ func (s *ServiceOfferingService) GetServiceOfferingByName(name string) (*Service
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ServiceOfferingService) GetServiceOfferingByID(id string) (*ServiceOffering, int, error) {
func (s *ServiceOfferingService) GetServiceOfferingByID(id string, opts ...OptionFunc) (*ServiceOffering, int, error) {
p := &ListServiceOfferingsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListServiceOfferings(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -374,27 +374,23 @@ func (s *SnapshotService) NewListSnapshotsParams() *ListSnapshotsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SnapshotService) GetSnapshotID(name string) (string, error) {
func (s *SnapshotService) GetSnapshotID(name string, opts ...OptionFunc) (string, error) {
p := &ListSnapshotsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListSnapshots(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListSnapshots(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -414,13 +410,13 @@ func (s *SnapshotService) GetSnapshotID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SnapshotService) GetSnapshotByName(name string) (*Snapshot, int, error) {
id, err := s.GetSnapshotID(name)
func (s *SnapshotService) GetSnapshotByName(name string, opts ...OptionFunc) (*Snapshot, int, error) {
id, err := s.GetSnapshotID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetSnapshotByID(id)
r, count, err := s.GetSnapshotByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -428,12 +424,18 @@ func (s *SnapshotService) GetSnapshotByName(name string) (*Snapshot, int, error)
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SnapshotService) GetSnapshotByID(id string) (*Snapshot, int, error) {
func (s *SnapshotService) GetSnapshotByID(id string, opts ...OptionFunc) (*Snapshot, int, error) {
p := &ListSnapshotsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListSnapshots(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -444,21 +446,6 @@ func (s *SnapshotService) GetSnapshotByID(id string) (*Snapshot, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListSnapshots(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)
}
@ -955,12 +942,18 @@ func (s *SnapshotService) NewListSnapshotPoliciesParams() *ListSnapshotPoliciesP
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SnapshotService) GetSnapshotPolicyByID(id string) (*SnapshotPolicy, int, error) {
func (s *SnapshotService) GetSnapshotPolicyByID(id string, opts ...OptionFunc) (*SnapshotPolicy, int, error) {
p := &ListSnapshotPoliciesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListSnapshotPolicies(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1282,27 +1275,23 @@ func (s *SnapshotService) NewListVMSnapshotParams() *ListVMSnapshotParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SnapshotService) GetVMSnapshotID(name string) (string, error) {
func (s *SnapshotService) GetVMSnapshotID(name string, opts ...OptionFunc) (string, error) {
p := &ListVMSnapshotParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListVMSnapshot(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVMSnapshot(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -182,12 +182,18 @@ func (s *SwiftService) NewListSwiftsParams() *ListSwiftsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SwiftService) GetSwiftID(keyword string) (string, error) {
func (s *SwiftService) GetSwiftID(keyword string, opts ...OptionFunc) (string, error) {
p := &ListSwiftsParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListSwifts(p)
if err != nil {
return "", err

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -572,12 +572,18 @@ func (s *SystemVMService) NewListSystemVmsParams() *ListSystemVmsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SystemVMService) GetSystemVmID(name string) (string, error) {
func (s *SystemVMService) GetSystemVmID(name string, opts ...OptionFunc) (string, error) {
p := &ListSystemVmsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListSystemVms(p)
if err != nil {
return "", err
@ -602,13 +608,13 @@ func (s *SystemVMService) GetSystemVmID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SystemVMService) GetSystemVmByName(name string) (*SystemVm, int, error) {
id, err := s.GetSystemVmID(name)
func (s *SystemVMService) GetSystemVmByName(name string, opts ...OptionFunc) (*SystemVm, int, error) {
id, err := s.GetSystemVmID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetSystemVmByID(id)
r, count, err := s.GetSystemVmByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -616,12 +622,18 @@ func (s *SystemVMService) GetSystemVmByName(name string) (*SystemVm, int, error)
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *SystemVMService) GetSystemVmByID(id string) (*SystemVm, int, error) {
func (s *SystemVMService) GetSystemVmByID(id string, opts ...OptionFunc) (*SystemVm, int, error) {
p := &ListSystemVmsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListSystemVms(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -1314,7 +1314,7 @@ func (s *TemplateService) NewListTemplatesParams(templatefilter string) *ListTem
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *TemplateService) GetTemplateID(name string, templatefilter string, zoneid string) (string, error) {
func (s *TemplateService) GetTemplateID(name string, templatefilter string, zoneid string, opts ...OptionFunc) (string, error) {
p := &ListTemplatesParams{}
p.p = make(map[string]interface{})
@ -1322,21 +1322,17 @@ func (s *TemplateService) GetTemplateID(name string, templatefilter string, zone
p.p["templatefilter"] = templatefilter
p.p["zoneid"] = zoneid
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListTemplates(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListTemplates(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -1356,13 +1352,13 @@ func (s *TemplateService) GetTemplateID(name string, templatefilter string, zone
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *TemplateService) GetTemplateByName(name string, templatefilter string, zoneid string) (*Template, int, error) {
id, err := s.GetTemplateID(name, templatefilter, zoneid)
func (s *TemplateService) GetTemplateByName(name string, templatefilter string, zoneid string, opts ...OptionFunc) (*Template, int, error) {
id, err := s.GetTemplateID(name, templatefilter, zoneid, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetTemplateByID(id, templatefilter)
r, count, err := s.GetTemplateByID(id, templatefilter, opts...)
if err != nil {
return nil, count, err
}
@ -1370,13 +1366,19 @@ func (s *TemplateService) GetTemplateByName(name string, templatefilter string,
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *TemplateService) GetTemplateByID(id string, templatefilter string) (*Template, int, error) {
func (s *TemplateService) GetTemplateByID(id string, templatefilter string, opts ...OptionFunc) (*Template, int, error) {
p := &ListTemplatesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
p.p["templatefilter"] = templatefilter
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListTemplates(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1387,21 +1389,6 @@ func (s *TemplateService) GetTemplateByID(id string, templatefilter string) (*Te
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListTemplates(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)
}
@ -1636,13 +1623,19 @@ func (s *TemplateService) NewListTemplatePermissionsParams(id string) *ListTempl
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *TemplateService) GetTemplatePermissionByID(id string) (*TemplatePermission, int, error) {
func (s *TemplateService) GetTemplatePermissionByID(id string, opts ...OptionFunc) (*TemplatePermission, int, error) {
p := &ListTemplatePermissionsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListTemplatePermissions(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -202,12 +202,18 @@ func (s *UCSService) NewListUcsManagersParams() *ListUcsManagersParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *UCSService) GetUcsManagerID(keyword string) (string, error) {
func (s *UCSService) GetUcsManagerID(keyword string, opts ...OptionFunc) (string, error) {
p := &ListUcsManagersParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListUcsManagers(p)
if err != nil {
return "", err
@ -232,13 +238,13 @@ func (s *UCSService) GetUcsManagerID(keyword string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *UCSService) GetUcsManagerByName(name string) (*UcsManager, int, error) {
id, err := s.GetUcsManagerID(name)
func (s *UCSService) GetUcsManagerByName(name string, opts ...OptionFunc) (*UcsManager, int, error) {
id, err := s.GetUcsManagerID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetUcsManagerByID(id)
r, count, err := s.GetUcsManagerByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -246,12 +252,18 @@ func (s *UCSService) GetUcsManagerByName(name string) (*UcsManager, int, error)
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *UCSService) GetUcsManagerByID(id string) (*UcsManager, int, error) {
func (s *UCSService) GetUcsManagerByID(id string, opts ...OptionFunc) (*UcsManager, int, error) {
p := &ListUcsManagersParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListUcsManagers(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -325,13 +325,19 @@ func (s *UsageService) NewListTrafficTypesParams(physicalnetworkid string) *List
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *UsageService) GetTrafficTypeID(keyword string, physicalnetworkid string) (string, error) {
func (s *UsageService) GetTrafficTypeID(keyword string, physicalnetworkid string, opts ...OptionFunc) (string, error) {
p := &ListTrafficTypesParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
p.p["physicalnetworkid"] = physicalnetworkid
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListTrafficTypes(p)
if err != nil {
return "", err

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -535,12 +535,18 @@ func (s *UserService) NewListUsersParams() *ListUsersParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *UserService) GetUserByID(id string) (*User, int, error) {
func (s *UserService) GetUserByID(id string, opts ...OptionFunc) (*User, int, error) {
p := &ListUsersParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListUsers(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -489,12 +489,18 @@ func (s *VLANService) NewListVlanIpRangesParams() *ListVlanIpRangesParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VLANService) GetVlanIpRangeByID(id string) (*VlanIpRange, int, error) {
func (s *VLANService) GetVlanIpRangeByID(id string, opts ...OptionFunc) (*VlanIpRange, int, error) {
p := &ListVlanIpRangesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListVlanIpRanges(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -505,21 +511,6 @@ func (s *VLANService) GetVlanIpRangeByID(id string) (*VlanIpRange, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVlanIpRanges(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)
}
@ -879,12 +870,18 @@ func (s *VLANService) NewListDedicatedGuestVlanRangesParams() *ListDedicatedGues
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VLANService) GetDedicatedGuestVlanRangeByID(id string) (*DedicatedGuestVlanRange, int, error) {
func (s *VLANService) GetDedicatedGuestVlanRangeByID(id string, opts ...OptionFunc) (*DedicatedGuestVlanRange, int, error) {
p := &ListDedicatedGuestVlanRangesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListDedicatedGuestVlanRanges(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -895,21 +892,6 @@ func (s *VLANService) GetDedicatedGuestVlanRangeByID(id string) (*DedicatedGuest
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListDedicatedGuestVlanRanges(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -368,27 +368,23 @@ func (s *VMGroupService) NewListInstanceGroupsParams() *ListInstanceGroupsParams
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VMGroupService) GetInstanceGroupID(name string) (string, error) {
func (s *VMGroupService) GetInstanceGroupID(name string, opts ...OptionFunc) (string, error) {
p := &ListInstanceGroupsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListInstanceGroups(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListInstanceGroups(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -408,13 +404,13 @@ func (s *VMGroupService) GetInstanceGroupID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VMGroupService) GetInstanceGroupByName(name string) (*InstanceGroup, int, error) {
id, err := s.GetInstanceGroupID(name)
func (s *VMGroupService) GetInstanceGroupByName(name string, opts ...OptionFunc) (*InstanceGroup, int, error) {
id, err := s.GetInstanceGroupID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetInstanceGroupByID(id)
r, count, err := s.GetInstanceGroupByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -422,12 +418,18 @@ func (s *VMGroupService) GetInstanceGroupByName(name string) (*InstanceGroup, in
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VMGroupService) GetInstanceGroupByID(id string) (*InstanceGroup, int, error) {
func (s *VMGroupService) GetInstanceGroupByID(id string, opts ...OptionFunc) (*InstanceGroup, int, error) {
p := &ListInstanceGroupsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListInstanceGroups(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -438,21 +440,6 @@ func (s *VMGroupService) GetInstanceGroupByID(id string) (*InstanceGroup, int, e
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListInstanceGroups(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -578,27 +578,23 @@ func (s *VPCService) NewListVPCsParams() *ListVPCsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetVPCID(name string) (string, error) {
func (s *VPCService) GetVPCID(name string, opts ...OptionFunc) (string, error) {
p := &ListVPCsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListVPCs(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVPCs(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -618,13 +614,13 @@ func (s *VPCService) GetVPCID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetVPCByName(name string) (*VPC, int, error) {
id, err := s.GetVPCID(name)
func (s *VPCService) GetVPCByName(name string, opts ...OptionFunc) (*VPC, int, error) {
id, err := s.GetVPCID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetVPCByID(id)
r, count, err := s.GetVPCByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -632,12 +628,18 @@ func (s *VPCService) GetVPCByName(name string) (*VPC, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetVPCByID(id string) (*VPC, int, error) {
func (s *VPCService) GetVPCByID(id string, opts ...OptionFunc) (*VPC, int, error) {
p := &ListVPCsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListVPCs(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -648,21 +650,6 @@ func (s *VPCService) GetVPCByID(id string) (*VPC, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVPCs(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)
}
@ -1831,12 +1818,18 @@ func (s *VPCService) NewListVPCOfferingsParams() *ListVPCOfferingsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetVPCOfferingID(name string) (string, error) {
func (s *VPCService) GetVPCOfferingID(name string, opts ...OptionFunc) (string, error) {
p := &ListVPCOfferingsParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListVPCOfferings(p)
if err != nil {
return "", err
@ -1861,13 +1854,13 @@ func (s *VPCService) GetVPCOfferingID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetVPCOfferingByName(name string) (*VPCOffering, int, error) {
id, err := s.GetVPCOfferingID(name)
func (s *VPCService) GetVPCOfferingByName(name string, opts ...OptionFunc) (*VPCOffering, int, error) {
id, err := s.GetVPCOfferingID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetVPCOfferingByID(id)
r, count, err := s.GetVPCOfferingByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -1875,12 +1868,18 @@ func (s *VPCService) GetVPCOfferingByName(name string) (*VPCOffering, int, error
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetVPCOfferingByID(id string) (*VPCOffering, int, error) {
func (s *VPCService) GetVPCOfferingByID(id string, opts ...OptionFunc) (*VPCOffering, int, error) {
p := &ListVPCOfferingsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListVPCOfferings(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -2296,12 +2295,18 @@ func (s *VPCService) NewListPrivateGatewaysParams() *ListPrivateGatewaysParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetPrivateGatewayByID(id string) (*PrivateGateway, int, error) {
func (s *VPCService) GetPrivateGatewayByID(id string, opts ...OptionFunc) (*PrivateGateway, int, error) {
p := &ListPrivateGatewaysParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListPrivateGateways(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -2312,21 +2317,6 @@ func (s *VPCService) GetPrivateGatewayByID(id string) (*PrivateGateway, int, err
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListPrivateGateways(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)
}
@ -2776,12 +2766,18 @@ func (s *VPCService) NewListStaticRoutesParams() *ListStaticRoutesParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetStaticRouteByID(id string) (*StaticRoute, int, error) {
func (s *VPCService) GetStaticRouteByID(id string, opts ...OptionFunc) (*StaticRoute, int, error) {
p := &ListStaticRoutesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListStaticRoutes(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -2792,21 +2788,6 @@ func (s *VPCService) GetStaticRouteByID(id string) (*StaticRoute, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListStaticRoutes(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -388,12 +388,18 @@ func (s *VPNService) NewListRemoteAccessVpnsParams() *ListRemoteAccessVpnsParams
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPNService) GetRemoteAccessVpnByID(id string) (*RemoteAccessVpn, int, error) {
func (s *VPNService) GetRemoteAccessVpnByID(id string, opts ...OptionFunc) (*RemoteAccessVpn, int, error) {
p := &ListRemoteAccessVpnsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListRemoteAccessVpns(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -404,21 +410,6 @@ func (s *VPNService) GetRemoteAccessVpnByID(id string) (*RemoteAccessVpn, int, e
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListRemoteAccessVpns(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)
}
@ -926,12 +917,18 @@ func (s *VPNService) NewListVpnUsersParams() *ListVpnUsersParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPNService) GetVpnUserByID(id string) (*VpnUser, int, error) {
func (s *VPNService) GetVpnUserByID(id string, opts ...OptionFunc) (*VpnUser, int, error) {
p := &ListVpnUsersParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListVpnUsers(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -942,21 +939,6 @@ func (s *VPNService) GetVpnUserByID(id string) (*VpnUser, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVpnUsers(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)
}
@ -2115,27 +2097,23 @@ func (s *VPNService) NewListVpnCustomerGatewaysParams() *ListVpnCustomerGateways
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPNService) GetVpnCustomerGatewayID(keyword string) (string, error) {
func (s *VPNService) GetVpnCustomerGatewayID(keyword string, opts ...OptionFunc) (string, error) {
p := &ListVpnCustomerGatewaysParams{}
p.p = make(map[string]interface{})
p.p["keyword"] = keyword
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListVpnCustomerGateways(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVpnCustomerGateways(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l)
}
@ -2155,13 +2133,13 @@ func (s *VPNService) GetVpnCustomerGatewayID(keyword string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPNService) GetVpnCustomerGatewayByName(name string) (*VpnCustomerGateway, int, error) {
id, err := s.GetVpnCustomerGatewayID(name)
func (s *VPNService) GetVpnCustomerGatewayByName(name string, opts ...OptionFunc) (*VpnCustomerGateway, int, error) {
id, err := s.GetVpnCustomerGatewayID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetVpnCustomerGatewayByID(id)
r, count, err := s.GetVpnCustomerGatewayByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -2169,12 +2147,18 @@ func (s *VPNService) GetVpnCustomerGatewayByName(name string) (*VpnCustomerGatew
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPNService) GetVpnCustomerGatewayByID(id string) (*VpnCustomerGateway, int, error) {
func (s *VPNService) GetVpnCustomerGatewayByID(id string, opts ...OptionFunc) (*VpnCustomerGateway, int, error) {
p := &ListVpnCustomerGatewaysParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListVpnCustomerGateways(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -2185,21 +2169,6 @@ func (s *VPNService) GetVpnCustomerGatewayByID(id string) (*VpnCustomerGateway,
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVpnCustomerGateways(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)
}
@ -2397,12 +2366,18 @@ func (s *VPNService) NewListVpnGatewaysParams() *ListVpnGatewaysParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPNService) GetVpnGatewayByID(id string) (*VpnGateway, int, error) {
func (s *VPNService) GetVpnGatewayByID(id string, opts ...OptionFunc) (*VpnGateway, int, error) {
p := &ListVpnGatewaysParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListVpnGateways(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -2413,21 +2388,6 @@ func (s *VPNService) GetVpnGatewayByID(id string) (*VpnGateway, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVpnGateways(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)
}
@ -2617,12 +2577,18 @@ func (s *VPNService) NewListVpnConnectionsParams() *ListVpnConnectionsParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPNService) GetVpnConnectionByID(id string) (*VpnConnection, int, error) {
func (s *VPNService) GetVpnConnectionByID(id string, opts ...OptionFunc) (*VpnConnection, int, error) {
p := &ListVpnConnectionsParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListVpnConnections(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -2633,21 +2599,6 @@ func (s *VPNService) GetVpnConnectionByID(id string) (*VpnConnection, int, error
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVpnConnections(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -2592,27 +2592,23 @@ func (s *VirtualMachineService) NewListVirtualMachinesParams() *ListVirtualMachi
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VirtualMachineService) GetVirtualMachineID(name string) (string, error) {
func (s *VirtualMachineService) GetVirtualMachineID(name string, opts ...OptionFunc) (string, error) {
p := &ListVirtualMachinesParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListVirtualMachines(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVirtualMachines(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -2632,13 +2628,13 @@ func (s *VirtualMachineService) GetVirtualMachineID(name string) (string, error)
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VirtualMachineService) GetVirtualMachineByName(name string) (*VirtualMachine, int, error) {
id, err := s.GetVirtualMachineID(name)
func (s *VirtualMachineService) GetVirtualMachineByName(name string, opts ...OptionFunc) (*VirtualMachine, int, error) {
id, err := s.GetVirtualMachineID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetVirtualMachineByID(id)
r, count, err := s.GetVirtualMachineByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -2646,12 +2642,18 @@ func (s *VirtualMachineService) GetVirtualMachineByName(name string) (*VirtualMa
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VirtualMachineService) GetVirtualMachineByID(id string) (*VirtualMachine, int, error) {
func (s *VirtualMachineService) GetVirtualMachineByID(id string, opts ...OptionFunc) (*VirtualMachine, int, error) {
p := &ListVirtualMachinesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListVirtualMachines(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -2662,21 +2664,6 @@ func (s *VirtualMachineService) GetVirtualMachineByID(id string) (*VirtualMachin
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVirtualMachines(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -1126,27 +1126,23 @@ func (s *VolumeService) NewListVolumesParams() *ListVolumesParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VolumeService) GetVolumeID(name string) (string, error) {
func (s *VolumeService) GetVolumeID(name string, opts ...OptionFunc) (string, error) {
p := &ListVolumesParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListVolumes(p)
if err != nil {
return "", err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVolumes(p)
if err != nil {
return "", err
}
}
if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l)
}
@ -1166,13 +1162,13 @@ func (s *VolumeService) GetVolumeID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VolumeService) GetVolumeByName(name string) (*Volume, int, error) {
id, err := s.GetVolumeID(name)
func (s *VolumeService) GetVolumeByName(name string, opts ...OptionFunc) (*Volume, int, error) {
id, err := s.GetVolumeID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetVolumeByID(id)
r, count, err := s.GetVolumeByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -1180,12 +1176,18 @@ func (s *VolumeService) GetVolumeByName(name string) (*Volume, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *VolumeService) GetVolumeByID(id string) (*Volume, int, error) {
func (s *VolumeService) GetVolumeByID(id string, opts ...OptionFunc) (*Volume, int, error) {
p := &ListVolumesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListVolumes(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(
@ -1196,21 +1198,6 @@ func (s *VolumeService) GetVolumeByID(id string) (*Volume, int, error) {
return nil, -1, err
}
if l.Count == 0 {
// If no matches, search all projects
p.p["projectid"] = "-1"
l, err = s.ListVolumes(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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -724,12 +724,18 @@ func (s *ZoneService) NewListZonesParams() *ListZonesParams {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ZoneService) GetZoneID(name string) (string, error) {
func (s *ZoneService) GetZoneID(name string, opts ...OptionFunc) (string, error) {
p := &ListZonesParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return "", err
}
}
l, err := s.ListZones(p)
if err != nil {
return "", err
@ -754,13 +760,13 @@ func (s *ZoneService) GetZoneID(name string) (string, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ZoneService) GetZoneByName(name string) (*Zone, int, error) {
id, err := s.GetZoneID(name)
func (s *ZoneService) GetZoneByName(name string, opts ...OptionFunc) (*Zone, int, error) {
id, err := s.GetZoneID(name, opts...)
if err != nil {
return nil, -1, err
}
r, count, err := s.GetZoneByID(id)
r, count, err := s.GetZoneByID(id, opts...)
if err != nil {
return nil, count, err
}
@ -768,12 +774,18 @@ func (s *ZoneService) GetZoneByName(name string) (*Zone, int, error) {
}
// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ZoneService) GetZoneByID(id string) (*Zone, int, error) {
func (s *ZoneService) GetZoneByID(id string, opts ...OptionFunc) (*Zone, int, error) {
p := &ListZonesParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
for _, fn := range opts {
if err := fn(s.cs, p); err != nil {
return nil, -1, err
}
}
l, err := s.ListZones(p)
if err != nil {
if strings.Contains(err.Error(), fmt.Sprintf(

View File

@ -1,5 +1,5 @@
//
// Copyright 2014, Sander van Harmelen
// Copyright 2016, Sander van Harmelen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -28,11 +28,25 @@ import (
"io/ioutil"
"net/http"
"net/url"
"regexp"
"sort"
"strings"
"time"
)
// UnlimitedResourceID is a special ID to define an unlimited resource
const UnlimitedResourceID = "-1"
var idRegex = regexp.MustCompile(`^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|-1)$`)
// IsID return true if the passed ID is either a UUID or a UnlimitedResourceID
func IsID(id string) bool {
return idRegex.MatchString(id)
}
// OptionFunc can be passed to the courtesy helper functions to set additional parameters
type OptionFunc func(*CloudStackClient, interface{}) error
type CSError struct {
ErrorCode int `json:"errorcode"`
CSErrorCode int `json:"cserrorcode"`
@ -369,6 +383,34 @@ func getRawValue(b json.RawMessage) (json.RawMessage, error) {
return nil, fmt.Errorf("Unable to extract the raw value from:\n\n%s\n\n", string(b))
}
// ProjectIDSetter is an interface that every type that can set a project ID must implement
type ProjectIDSetter interface {
SetProjectid(string)
}
// WithProject takes either a project name or ID and sets the `projectid` parameter
func WithProject(project string) OptionFunc {
return func(cs *CloudStackClient, p interface{}) error {
ps, ok := p.(ProjectIDSetter)
if !ok || project == "" {
return nil
}
if !IsID(project) {
id, err := cs.Project.GetProjectID(project)
if err != nil {
return err
}
project = id
}
ps.SetProjectid(project)
return nil
}
}
type APIDiscoveryService struct {
cs *CloudStackClient
}