-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Get All Workspaces * Update timeout
- Loading branch information
1 parent
9863b8d
commit 750fdf5
Showing
3 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
v "github.com/IBM-Cloud/power-go-client/clients/instance" | ||
ps "github.com/IBM-Cloud/power-go-client/ibmpisession" | ||
|
||
"github.com/IBM/go-sdk-core/v5/core" | ||
) | ||
|
||
func main() { | ||
// token := "" | ||
apiKey := "" | ||
region := "" | ||
zone := "" | ||
accountID := "" | ||
url := region + ".power-iaas.test.cloud.ibm.com" | ||
|
||
piID := "" | ||
// authenticator := &core.BearerTokenAuthenticator{ | ||
// BearerToken: token, | ||
// } | ||
authenticator := &core.IamAuthenticator{ | ||
ApiKey: apiKey, | ||
// Uncomment for test environment | ||
URL: "https://iam.test.cloud.ibm.com", | ||
} | ||
// Create the session | ||
options := &ps.IBMPIOptions{ | ||
Authenticator: authenticator, | ||
UserAccount: accountID, | ||
Zone: zone, | ||
URL: url, | ||
Debug: true, | ||
} | ||
|
||
session, err := ps.NewIBMPISession(options) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
powerClient := v.NewIBMPIDatacenterClient(context.Background(), session, piID) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
getDatacenter, err := powerClient.Get("dal12") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Printf("***************[0]****************** %+v \n", getDatacenter) | ||
getDatacenters, err := powerClient.GetAll() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Printf("***************[1]****************** %+v \n", getDatacenters) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters