From 46704f234320252556445b9a7affc488590a2f30 Mon Sep 17 00:00:00 2001 From: vladhanzha Date: Mon, 22 Jul 2024 15:00:36 +0300 Subject: [PATCH] Add get application by name function --- cloudconnexa/applications.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cloudconnexa/applications.go b/cloudconnexa/applications.go index bbf66f4..4ed2f79 100644 --- a/cloudconnexa/applications.go +++ b/cloudconnexa/applications.go @@ -110,6 +110,20 @@ func (c *ApplicationsService) Get(id string) (*ApplicationResponse, error) { return &application, nil } +func (c *ApplicationsService) GetByName(name string) (*ApplicationResponse, error) { + applications, err := c.List() + if err != nil { + return nil, err + } + + for _, n := range applications { + if n.Name == name { + return &n, nil + } + } + return nil, nil +} + func (c *ApplicationsService) Create(application *Application) (*ApplicationResponse, error) { applicationJson, err := json.Marshal(application) if err != nil {