-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from chengxiangdong/feat_nic
feat: Add support for querying the primary network
- Loading branch information
Showing
11 changed files
with
462 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package model | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/def" | ||
) | ||
|
||
func GenReqDefForListServersDetails() *def.HttpRequestDef { | ||
reqDefBuilder := def.NewHttpRequestDefBuilder(). | ||
WithMethod(http.MethodGet). | ||
WithPath("/v1/{project_id}/cloudservers/detail"). | ||
WithResponse(new(ListServersDetailsResponse)). | ||
WithContentType("application/json") | ||
|
||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("EnterpriseProjectId"). | ||
WithJsonTag("enterprise_project_id"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("Flavor"). | ||
WithJsonTag("flavor"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("Ip"). | ||
WithJsonTag("ip"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("Limit"). | ||
WithJsonTag("limit"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("Name"). | ||
WithJsonTag("name"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("NotTags"). | ||
WithJsonTag("not-tags"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("Offset"). | ||
WithJsonTag("offset"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("ReservationId"). | ||
WithJsonTag("reservation_id"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("Status"). | ||
WithJsonTag("status"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("Tags"). | ||
WithJsonTag("tags"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("IpEq"). | ||
WithJsonTag("ip_eq"). | ||
WithLocationType(def.Query)) | ||
reqDefBuilder.WithRequestField(def.NewFieldDef(). | ||
WithName("ServerId"). | ||
WithJsonTag("server_id"). | ||
WithLocationType(def.Query)) | ||
|
||
requestDef := reqDefBuilder.Build() | ||
return requestDef | ||
} |
28 changes: 28 additions & 0 deletions
28
pkg/cloudprovider/huaweicloud/model/model_list_servers_details_response.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// nolint: golint | ||
package model | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/utils" | ||
) | ||
|
||
// Response Object | ||
type ListServersDetailsResponse struct { | ||
|
||
// 弹性云服务器的列表总数。 | ||
Count *int32 `json:"count,omitempty"` | ||
|
||
// 弹性云服务器详情列表,具体参照-查询云服务器详情接口。查询级别不同,返回的详情不同。 | ||
Servers *[]ServerDetail `json:"servers,omitempty"` | ||
HttpStatusCode int `json:"-"` | ||
} | ||
|
||
func (o ListServersDetailsResponse) String() string { | ||
data, err := utils.Marshal(o) | ||
if err != nil { | ||
return "ListServersDetailsResponse struct{}" | ||
} | ||
|
||
return strings.Join([]string{"ListServersDetailsResponse", string(data)}, " ") | ||
} |
84 changes: 84 additions & 0 deletions
84
pkg/cloudprovider/huaweicloud/model/model_server_address.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// nolint: golint | ||
package model | ||
|
||
import ( | ||
"errors" | ||
"strings" | ||
|
||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/utils" | ||
|
||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/converter" | ||
) | ||
|
||
// 弹性云服务器的网络属性。 | ||
type ServerAddress struct { | ||
|
||
// IP地址版本。 - “4”:代表IPv4。 - “6”:代表IPv6。 | ||
Version string `json:"version"` | ||
|
||
// IP地址。 | ||
Addr string `json:"addr"` | ||
|
||
// 是否主网卡 | ||
Primary bool `json:"primary"` | ||
|
||
// IP地址类型。 - fixed:代表私有IP地址。 - floating:代表浮动IP地址。 | ||
OSEXTIPStype *ServerAddressOSEXTIPStype `json:"OS-EXT-IPS:type,omitempty"` | ||
|
||
// MAC地址。 | ||
OSEXTIPSMACmacAddr *string `json:"OS-EXT-IPS-MAC:mac_addr,omitempty"` | ||
|
||
// IP地址对应的端口ID。 | ||
OSEXTIPSportId *string `json:"OS-EXT-IPS:port_id,omitempty"` | ||
} | ||
|
||
func (o ServerAddress) String() string { | ||
data, err := utils.Marshal(o) | ||
if err != nil { | ||
return "ServerAddress struct{}" | ||
} | ||
|
||
return strings.Join([]string{"ServerAddress", string(data)}, " ") | ||
} | ||
|
||
type ServerAddressOSEXTIPStype struct { | ||
value string | ||
} | ||
|
||
type ServerAddressOSEXTIPStypeEnum struct { | ||
FIXED ServerAddressOSEXTIPStype | ||
FLOATING ServerAddressOSEXTIPStype | ||
} | ||
|
||
func GetServerAddressOSEXTIPStypeEnum() ServerAddressOSEXTIPStypeEnum { | ||
return ServerAddressOSEXTIPStypeEnum{ | ||
FIXED: ServerAddressOSEXTIPStype{ | ||
value: "fixed", | ||
}, | ||
FLOATING: ServerAddressOSEXTIPStype{ | ||
value: "floating", | ||
}, | ||
} | ||
} | ||
|
||
func (c ServerAddressOSEXTIPStype) Value() string { | ||
return c.value | ||
} | ||
|
||
func (c ServerAddressOSEXTIPStype) MarshalJSON() ([]byte, error) { | ||
return utils.Marshal(c.value) | ||
} | ||
|
||
func (c *ServerAddressOSEXTIPStype) UnmarshalJSON(b []byte) error { | ||
myConverter := converter.StringConverterFactory("string") | ||
if myConverter != nil { | ||
val, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\"")) | ||
if err == nil { | ||
c.value = val.(string) | ||
return nil | ||
} | ||
return err | ||
} else { | ||
return errors.New("convert enum data to string error") | ||
} | ||
} |
Oops, something went wrong.