forked from uyuni-project/uyuni-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetDetails.go
More file actions
37 lines (32 loc) · 1019 Bytes
/
Copy pathgetDetails.go
File metadata and controls
37 lines (32 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-FileCopyrightText: 2026 SUSE LLC
//
// SPDX-License-Identifier: Apache-2.0
package org
import (
"errors"
"fmt"
"github.com/uyuni-project/uyuni-tools/shared/api"
"github.com/uyuni-project/uyuni-tools/shared/api/types"
. "github.com/uyuni-project/uyuni-tools/shared/l10n"
"github.com/uyuni-project/uyuni-tools/shared/utils"
)
// GetOrganizationDetails gets details of organization based on organization name.
func GetOrganizationDetails(cnxDetails *api.ConnectionDetails, orgName string) (*types.Organization, error) {
client, err := api.Init(cnxDetails)
if err == nil {
err = client.Login()
}
if err != nil {
return nil, utils.Errorf(err, L("failed to connect to the server"))
}
res, err := api.GetChecked[types.Organization](
client, fmt.Sprintf("org/getDetails?name=%s", orgName), "api.org.get_details",
)
if err != nil {
return nil, utils.Errorf(err, L("failed to get organization details"))
}
if !res.Success {
return nil, errors.New(res.Message)
}
return &res.Result, nil
}