diff --git a/management/server/http/api/openapi.yml b/management/server/http/api/openapi.yml index cf22cf954a7..932d4bfdd69 100644 --- a/management/server/http/api/openapi.yml +++ b/management/server/http/api/openapi.yml @@ -1272,17 +1272,18 @@ components: description: Network resource description type: string example: A remote resource inside network 1 + address: + description: Network resource address (either a direct host like 1.1.1.1 or 1.1.1.1/32, or a subnet like 192.168.178.0/24, or domains like example.com and *.example.com) + type: string + example: "1.1.1.1" required: - name + - address NetworkResourceRequest: allOf: - $ref: '#/components/schemas/NetworkResourceMinimum' - type: object properties: - address: - description: Network resource address (either a direct host like 1.1.1.1 or 1.1.1.1/32, or a subnet like 192.168.178.0/24, or a domain like example.com) - type: string - example: "1.1.1.1" groups: description: Group IDs containing the resource type: array @@ -1307,20 +1308,10 @@ components: type: array items: $ref: '#/components/schemas/GroupMinimum' - domain: - description: Domain name of the resource - type: string - example: example.com - prefix: - description: Prefix of the resource - type: string - example: required: - id - type - groups - - domain - - prefix - $ref: '#/components/schemas/NetworkResourceMinimum' NetworkResourceType: description: Network resource type based of the address diff --git a/management/server/http/api/types.gen.go b/management/server/http/api/types.gen.go index e0bd78c42a7..80aff514a33 100644 --- a/management/server/http/api/types.gen.go +++ b/management/server/http/api/types.gen.go @@ -551,12 +551,12 @@ type NetworkRequest struct { // NetworkResource defines model for NetworkResource. type NetworkResource struct { + // Address Network resource address (either a direct host like 1.1.1.1 or 1.1.1.1/32, or a subnet like 192.168.178.0/24, or a domain like example.com) + Address string `json:"address"` + // Description Network resource description Description *string `json:"description,omitempty"` - // Domain Domain name of the resource - Domain string `json:"domain"` - // Groups Groups that the resource belongs to Groups []GroupMinimum `json:"groups"` @@ -566,15 +566,15 @@ type NetworkResource struct { // Name Network resource name Name string `json:"name"` - // Prefix Prefix of the resource - Prefix string `json:"prefix"` - // Type Network resource type based of the address Type NetworkResourceType `json:"type"` } // NetworkResourceMinimum defines model for NetworkResourceMinimum. type NetworkResourceMinimum struct { + // Address Network resource address (either a direct host like 1.1.1.1 or 1.1.1.1/32, or a subnet like 192.168.178.0/24, or a domain like example.com) + Address string `json:"address"` + // Description Network resource description Description *string `json:"description,omitempty"` diff --git a/management/server/networks/resources/types/resource.go b/management/server/networks/resources/types/resource.go index 7d5eba869b1..63a915f198f 100644 --- a/management/server/networks/resources/types/resource.go +++ b/management/server/networks/resources/types/resource.go @@ -55,13 +55,17 @@ func NewNetworkResource(accountID, networkID, name, description, address string) } func (n *NetworkResource) ToAPIResponse(groups []api.GroupMinimum) *api.NetworkResource { + addr := n.Prefix.String() + if n.Type == domain { + addr = n.Domain + } + return &api.NetworkResource{ Id: n.ID, Name: n.Name, Description: &n.Description, Type: api.NetworkResourceType(n.Type.String()), - Domain: n.Domain, - Prefix: n.Prefix.String(), + Address: addr, Groups: groups, } }