Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
enable mart whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Jul 25, 2019
1 parent e338863 commit 169a804
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ The following parameters are supported. See Common Reference for a list of addit

* [list](#listorgs)
* [get](#getorg)
* [setmart](#setmart)

### <a name="listorgs"/> list

Expand All @@ -576,6 +577,20 @@ The following parameters are supported. See Common Reference for a list of addit

* `--org -o` (required) Apigee organization name

### <a name="setmart"/> setmart

Configure MART endpoint for an Apigee Org

```
apigeecli org get -o org -m http://endpoint
```
Parameters
The following parameters are supported. See Common Reference for a list of additional parameters.

* `--org -o` (required) Apigee organization name
* `--mart -m` (required) MART endpoint
* `--whitelist -w` (optional) Enable/disable whitelisting of GCP IP for source connections to MART

---

## <a name="prods"/> products
Expand Down
19 changes: 16 additions & 3 deletions cmd/org/setmart/setmart.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,36 @@ var Cmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
u, _ := url.Parse(shared.BaseURL)
orgname := "\"name\":\"" + shared.RootArgs.Org + "\","
martprop := "{\"name\":\"features.mart.server.endpoint\","
martpropvalue := "\"value\":\"" + mart + "\"}"
props := "\"properties\": {" + "\"property\": [" + martprop + martpropvalue + "]}"
hybridprop := "{\"name\" : \"features.hybrid.enabled\", \"value\" : \"true\"},"
martprop := "{\"name\":\"features.mart.server.endpoint\", \"value\":\"" + mart + "\"}"

props := "\"properties\": {" + "\"property\": [" + hybridprop + martprop

if whitelist {
whitelistprop := "{\"name\":\"features.mart.server.endpoint\", \"value\" : \"true\"}"
props = props + "," + whitelistprop
}

props = props + "]}"

payload := "{" + orgname + props + "}"
u.Path = path.Join(u.Path, shared.RootArgs.Org)
return shared.HttpClient(u.String(), payload)
},
}

var mart string
var whitelist bool

func init() {

Cmd.Flags().StringVarP(&shared.RootArgs.Org, "org", "o",
"", "Apigee organization name")
Cmd.Flags().StringVarP(&mart, "mart", "m",
"", "MART Endpoint")
Cmd.Flags().BoolVarP(&whitelist, "whitelist", "w",
false, "Whitelist GCP Source IP")

_ = Cmd.MarkFlagRequired("org")
_ = Cmd.MarkFlagRequired("mart")
}
9 changes: 9 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ func TestSetMart(t *testing.T) {
}
}

func TestSetMartWhiteList(t *testing.T) {
mart := os.Getenv("MART")
cmd := exec.Command(apigeecli, "orgs", "setmart", "-o", org, "-m", mart, "-w", "false", "-t", token)
err := cmd.Run()
if err != nil {
t.Fatal(err)
}
}

// env tests
func TestListEnvs(t *testing.T) {
cmd := exec.Command(apigeecli, "envs", "list", "-o", org, "-t", token)
Expand Down

0 comments on commit 169a804

Please sign in to comment.