Skip to content

Commit 6a21127

Browse files
committed
readMe structure
1 parent ee14231 commit 6a21127

File tree

5 files changed

+709
-45
lines changed

5 files changed

+709
-45
lines changed

README.md

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ Contains code samples to invoke NetBackup REST API using different programming l
66
These scripts are only meant to be used as a reference. Please do not use these in production.
77

88
#### Executing the snippets for different programming languages
9-
#### Executing the snippets in PowerShell
10-
Pre-requisites:
11-
- NetBackup 8.1.1 or higher
12-
- Powershell 5.0 or higher
13-
14-
Use the following commands to run the powershell samples.
15-
- `.\Get-NB-Images.ps1 -nbmaster <masterServer> -username <username> -password <password>`
16-
- `.\Get-NB-Jobs.ps1 -nbmaster <masterServer> -username <username> -password <password>`
17-
- `.\New-Policy-StepByStep.ps1 -nbmaster <masterServer> -username <username> -password <password>`
189

1910
The `snippets` folder contains code samples to invoke NetBackup REST API using different programming languages.
2011

@@ -23,49 +14,17 @@ Pre-requisites:
2314
- NetBackup 8.1.1 or higher
2415
- See the script's README for the corresponding requirements and usage
2516

26-
#### Executing the recipes in Perl
2717

28-
Pre-requisites:
29-
- NetBackup 8.1.2 or higher
30-
- Perl 5.20.2 or higher
18+
#### Executing the recipes for different programming languages
3119

32-
Use the following commands to run the perl samples.
33-
- `perl create_policy_step_by_step.pl -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
34-
- `perl create_policy_in_one_step.pl -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
35-
- `perl rbac_filtering_in_policy.pl -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
36-
- `perl api_requests_images.pl -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
37-
- `perl api_requests_image_contents.pl -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
38-
39-
#### Executing the recipes in Python
20+
The `recipes` folder contains code samples to invoke NetBackup REST API using different programming languages.
4021

4122
Pre-requisites:
42-
- NetBackup 8.1.2 or higher
43-
- python 3.5 or higher
44-
- python modules: `requests`
45-
46-
Use the following commands to run the python samples.
47-
- `python -W ignore create_policy_step_by_step.py -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
48-
- `python -W ignore create_policy_in_one_step.py -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
49-
- `python -W ignore rbac_filtering_in_policy.py -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]`
50-
5123

52-
#### Tools
53-
The `tools` folder contains utilities that have proven useful in the development of projects using
54-
NetBackup REST APIs, but do not provide any API usage examples. Again, these tools are not for
55-
production use, but they may be of some use in your work.
56-
57-
Use the following commands to run the curl samples.
58-
- `./get_nb_jobs.sh -master <master_server> -username <username> -password <password>`
59-
- `./get_nb_images.sh -master <master_server> -username <username> -password <password>`
60-
61-
#### Executing the recipes using go (often referred to as golang)
62-
Pre-requisites:
6324
- NetBackup 8.1.2 or higher
64-
- go1.10.2 or higher
25+
- See the script's README for the corresponding requirements and usage
26+
6527

66-
Use the following commands to run the go samples.
67-
- `go run ./create_policy_step_by_step.go -nbmaster <master_server> -username <username> -password <password>`
68-
- `go run ./create_policy_in_one_step.go -nbmaster <master_server> -username <username> -password <password>`
6928

7029
#### Tools
7130
The `tools` folder contains utilities that have proven useful in the development of projects using

recipes/go/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### NetBackup API Code Samples for go (often referred to as golang)
2+
3+
This directory contains code samples to invoke NetBackup REST APIs using go.
4+
5+
#### Disclaimer
6+
7+
These scripts are only meant to be used as a reference. If you intend to use them in production, use it at your own risk.
8+
9+
#### Pre-requisites:
10+
11+
- NetBackup 8.1.2 or higher
12+
- go1.10.2 or higher
13+
14+
#### Executing the recipes using go
15+
16+
Use the following commands to run the go samples.
17+
- `go run ./create_policy_step_by_step.go -nbmaster <master_server> -username <username> -password <password>`
18+
- `go run ./create_policy_in_one_step.go -nbmaster <master_server> -username <username> -password <password>`
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//This script can be run using NetBackup 8.1.2 and higher.
2+
//It creates a VMware policy consisting of the specific attribute values, a client, a schedule, and a VIP query backup selection
3+
//and eventually deletes the policy.
4+
5+
package main
6+
7+
import (
8+
"flag"
9+
"fmt"
10+
"log"
11+
"os"
12+
"policies/apihelper"
13+
)
14+
15+
//###################
16+
// Global Variables
17+
//###################
18+
var (
19+
nbmaster = flag.String("nbmaster", "", "NetBackup Master Server")
20+
username = flag.String("username", "", "User name to log into the NetBackup webservices")
21+
password = flag.String("password", "", "Password for the given user")
22+
domainName = flag.String("domainName", "", "Domain name of the given user")
23+
domainType = flag.String("domainType", "", "Domain type of the given user")
24+
)
25+
26+
const usage = "\n\nUsage: go run ./create_policy_in_one_step.go -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]\n\n"
27+
28+
func main() {
29+
// Print usage
30+
flag.Usage = func() {
31+
fmt.Fprintf(os.Stderr, usage)
32+
os.Exit(1)
33+
}
34+
35+
// Read command line arguments
36+
flag.Parse()
37+
38+
if len(*nbmaster) == 0 {
39+
log.Fatalf("Please specify the name of the NetBackup Master Server using the -nbmaster parameter.\n")
40+
}
41+
if len(*username) == 0 {
42+
log.Fatalf("Please specify the username using the -username parameter.\n")
43+
}
44+
if len(*password) == 0 {
45+
log.Fatalf("Please specify the password using the -password parameter.\n")
46+
}
47+
48+
httpClient := helper.GetHTTPClient()
49+
jwt := helper.Login(*nbmaster, httpClient, *username, *password, *domainName, *domainType)
50+
51+
helper.CreatePolicy(*nbmaster, httpClient, jwt)
52+
helper.ListPolicies(*nbmaster, httpClient, jwt)
53+
helper.ReadPolicy(*nbmaster, httpClient, jwt)
54+
helper.DeletePolicy(*nbmaster, httpClient, jwt)
55+
helper.ListPolicies(*nbmaster, httpClient, jwt)
56+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//This script can be run using NetBackup 8.1.2 and higher.
2+
//It creates a VMware policy with the default attribute values, then adds a client, a schedule, and a VIP query backup selection to it.
3+
//It then delets the client, schedule from the policy and finally deletes the policy.
4+
5+
package main
6+
7+
import (
8+
"flag"
9+
"fmt"
10+
"log"
11+
"os"
12+
"policies/apihelper"
13+
)
14+
15+
//###################
16+
// Global Variables
17+
//###################
18+
var (
19+
nbmaster = flag.String("nbmaster", "", "NetBackup Master Server")
20+
username = flag.String("username", "", "User name to log into the NetBackup webservices")
21+
password = flag.String("password", "", "Password for the given user")
22+
domainName = flag.String("domainName", "", "Domain name of the given user")
23+
domainType = flag.String("domainType", "", "Domain type of the given user")
24+
)
25+
26+
const usage = "\n\nUsage: go run ./create_policy_step_by_step.go -nbmaster <masterServer> -username <username> -password <password> [-domainName <domainName>] [-domainType <domainType>]\n\n"
27+
28+
func main() {
29+
// Print usage
30+
flag.Usage = func() {
31+
fmt.Fprintf(os.Stderr, usage)
32+
os.Exit(1)
33+
}
34+
35+
// Read command line arguments
36+
flag.Parse()
37+
38+
if len(*nbmaster) == 0 {
39+
log.Fatalf("Please specify the name of the NetBackup Master Server using the -nbmaster parameter.\n")
40+
}
41+
if len(*username) == 0 {
42+
log.Fatalf("Please specify the username using the -username parameter.\n")
43+
}
44+
if len(*password) == 0 {
45+
log.Fatalf("Please specify the password using the -password parameter.\n")
46+
}
47+
48+
httpClient := helper.GetHTTPClient()
49+
jwt := helper.Login(*nbmaster, httpClient, *username, *password, *domainName, *domainType)
50+
51+
helper.CreatePolicyWithDefaults(*nbmaster, httpClient, jwt)
52+
helper.ListPolicies(*nbmaster, httpClient, jwt)
53+
helper.ReadPolicy(*nbmaster, httpClient, jwt)
54+
helper.AddClient(*nbmaster, httpClient, jwt)
55+
helper.AddSchedule(*nbmaster, httpClient, jwt)
56+
helper.AddBackupSelection(*nbmaster, httpClient, jwt)
57+
helper.ReadPolicy(*nbmaster, httpClient, jwt)
58+
helper.DeleteClient(*nbmaster, httpClient, jwt)
59+
helper.DeleteSchedule(*nbmaster, httpClient, jwt)
60+
helper.ReadPolicy(*nbmaster, httpClient, jwt)
61+
helper.DeletePolicy(*nbmaster, httpClient, jwt)
62+
helper.ListPolicies(*nbmaster, httpClient, jwt)
63+
}

0 commit comments

Comments
 (0)