Skip to content

Commit

Permalink
revert to sending addr field
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-fischer committed Dec 17, 2024
1 parent 228672a commit 94f73d2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
19 changes: 5 additions & 14 deletions management/server/http/api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 a domain like 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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions management/server/http/api/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions management/server/networks/resources/types/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down

0 comments on commit 94f73d2

Please sign in to comment.