v12.8.0
This commit is contained in:
47
pkg/sdn/logicalports/get_by_unique_identifier.go
Normal file
47
pkg/sdn/logicalports/get_by_unique_identifier.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package logicalports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetByUniqueIdentifierRequest struct to get information about logical port
|
||||
type GetByUniqueIdentifierRequest struct {
|
||||
// ID a logical port
|
||||
// Required: true
|
||||
ID string `url:"unique_identifier" json:"unique_identifier" validate:"required"`
|
||||
}
|
||||
|
||||
// GetByUniqueIdentifier gets logical port details as a LogicalPort struct
|
||||
func (a LogicalPorts) GetByUniqueIdentifier(ctx context.Context, req GetByUniqueIdentifierRequest) (*LogicalPort, error) {
|
||||
res, err := a.GetByUniqueIdentifierRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := LogicalPort{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
|
||||
}
|
||||
|
||||
// GetByUniqueIdentifier gets logical port details as an array of bytes
|
||||
func (a LogicalPorts) GetByUniqueIdentifierRaw(ctx context.Context, req GetByUniqueIdentifierRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/logical_port/get_by_unique_identifier"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user