-
Notifications
You must be signed in to change notification settings - Fork 5
/
getServiceSample.go
45 lines (38 loc) · 1.57 KB
/
getServiceSample.go
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
38
39
40
41
42
43
44
45
// Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved.
// Licensed under the Apache License, Version 2.0 (the "License"). You may not use
// this file except in compliance with the License. A copy of the License is located at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// or in the "license" file accompanying this file.
// This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
package functions
import (
"log"
"github.com/SpectraLogic/ds3_go_sdk/ds3/models"
"github.com/SpectraLogic/ds3_go_sdk/ds3/buildclient"
"fmt"
"github.com/SpectraLogic/ds3_go_sdk/samples/utils"
)
func GetServiceSample() {
fmt.Println("---- Get Service Sample ----")
// Create the client from environment variables.
client, err := buildclient.FromEnv()
if err != nil {
log.Fatal(err)
}
// Create the get service request. All requests to a DS3 appliance start this way.
request := models.NewGetServiceRequest()
// Perform the Get Service call by using the client and invoking the desired command.
response, err := client.GetService(request)
if err != nil {
log.Fatal(err)
}
// Printing contents of get service.
fmt.Println("Buckets:")
for i, bucket := range response.ListAllMyBucketsResult.Buckets {
fmt.Printf("%d) Name: %s; CreationDate: %s\n", i + 1, utils.ToSafeString(bucket.Name), utils.ToSafeString(bucket.CreationDate))
}
}