-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37921c8
commit f5c395e
Showing
12 changed files
with
453 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/paloaltonetworks/cloud-ngfw-aws-go/api/account" | ||
) | ||
|
||
func (c *ApiClient) CreateAccount(ctx context.Context, input account.CreateInput) (account.CreateOutput, error) { | ||
out, err := c.client.CreateAccount(ctx, input) | ||
if err != nil { | ||
return account.CreateOutput{}, err | ||
} | ||
return out, nil | ||
} | ||
|
||
func (c *ApiClient) ReadAccount(ctx context.Context, input account.ReadInput) (account.ReadOutput, error) { | ||
out, err := c.client.ReadAccount(ctx, input) | ||
if err != nil { | ||
return account.ReadOutput{}, err | ||
} | ||
return out, nil | ||
} | ||
|
||
func (c *ApiClient) ListAccounts(ctx context.Context, a account.ListInput) (account.ListOutput, error) { | ||
out, err := c.client.ListAccounts(ctx, a) | ||
if err != nil { | ||
return account.ListOutput{}, err | ||
} | ||
return out, nil | ||
} | ||
|
||
func (c *ApiClient) DeleteAccount(ctx context.Context, input account.DeleteInput) error { | ||
err := c.client.DeleteAccount(ctx, input) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
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,84 @@ | ||
package account | ||
|
||
import ( | ||
"github.com/paloaltonetworks/cloud-ngfw-aws-go/api/response" | ||
) | ||
|
||
// V1 create. | ||
type CreateInput struct { | ||
AccountId string `json:"AccountId,omitempty"` | ||
Origin string `json:"Origin,omitempty"` | ||
} | ||
|
||
type Info struct { | ||
TrustedAccount string `json:"ServiceAccountId,omitempty"` | ||
ExternalId string `json:"ExternalId,omitempty"` | ||
SNSTopicArn string `json:"SNSTopicArn,omitempty"` | ||
Origin string `json:"Origin,omitempty"` | ||
} | ||
|
||
type CreateOutput struct { | ||
Response Info `json:"Response"` | ||
Status response.Status `json:"ResponseStatus"` | ||
} | ||
|
||
// V1 read. | ||
type ReadInput struct { | ||
AccountId string `json:"AccountId,omitempty"` | ||
} | ||
|
||
type ReadOutput struct { | ||
Response ReadResponse `json:"Response"` | ||
Status response.Status `json:"ResponseStatus"` | ||
} | ||
|
||
func (o ReadOutput) Failed() *response.Status { | ||
return o.Status.Failed() | ||
} | ||
|
||
func (o CreateOutput) Failed() *response.Status { | ||
return o.Status.Failed() | ||
} | ||
|
||
type AccountDetail struct { | ||
AccountId string `json:"AccountId,omitempty"` | ||
CloudFormationTemplateURL string `json:"CloudFormationTemplateURL,omitempty"` | ||
OnboardingStatus string `json:"OnboardingStatus,omitempty"` | ||
ExternalId string `json:"ExternalId,omitempty"` | ||
ServiceAccountId string `json:"ServiceAccountId,omitempty"` | ||
SNSTopicArn string `json:"SNSTopicArn,omitempty"` | ||
} | ||
|
||
type ReadResponse struct { | ||
AccountDetail | ||
UpdateToken string `json:"UpdateToken,omitempty"` | ||
} | ||
|
||
type ListInput struct { | ||
Describe bool `json:"Describe,omitempty"` | ||
MaxResults int `json:"MaxResults,omitempty"` | ||
NextToken string `json:"NextToken,omitempty"` | ||
} | ||
|
||
type ListAccount struct { | ||
AccountId string | ||
} | ||
|
||
type ListResponse struct { | ||
AccountIds []string `json:"AccountIds"` | ||
AccountDetails []AccountDetail `json:"AccountDetails,omitempty"` | ||
NextToken string `json:"NextToken,omitempty"` | ||
} | ||
|
||
type ListOutput struct { | ||
Response ListResponse `json:"Response"` | ||
Status response.Status `json:"ResponseStatus"` | ||
} | ||
|
||
func (o ListOutput) Failed() *response.Status { | ||
return o.Status.Failed() | ||
} | ||
|
||
type DeleteInput struct { | ||
AccountId string `json:"AccountId"` | ||
} |
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
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
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,79 @@ | ||
package aws | ||
|
||
import ( | ||
"github.com/paloaltonetworks/cloud-ngfw-aws-go/api/account" | ||
"context" | ||
"net/http" | ||
) | ||
|
||
// Create creates an object. | ||
func (c *Client) CreateAccount(ctx context.Context, input account.CreateInput) (account.CreateOutput, error) { | ||
c.Log(http.MethodPost, "create account") | ||
|
||
var ans account.CreateOutput | ||
_, err := c.Communicate( | ||
ctx, | ||
PermissionAccount, | ||
http.MethodPost, | ||
[]string{"v1", "mgmt", "linkaccounts"}, | ||
nil, | ||
input, | ||
&ans, | ||
) | ||
|
||
return ans, err | ||
} | ||
|
||
// Read returns information on the given object. | ||
func (c *Client) ReadAccount(ctx context.Context, input account.ReadInput) (account.ReadOutput, error) { | ||
accountId := input.AccountId | ||
c.Log(http.MethodGet, "describe account: %s", accountId) | ||
|
||
var ans account.ReadOutput | ||
_, err := c.Communicate( | ||
ctx, | ||
PermissionAccount, | ||
http.MethodGet, | ||
[]string{"v1", "mgmt", "linkaccounts", accountId}, | ||
nil, | ||
nil, | ||
&ans, | ||
) | ||
|
||
return ans, err | ||
} | ||
|
||
// List returns a list of given objects. | ||
func (c *Client) ListAccounts(ctx context.Context, input account.ListInput) (account.ListOutput, error) { | ||
c.Log(http.MethodGet, "list accounts") | ||
|
||
var ans account.ListOutput | ||
_, err := c.Communicate( | ||
ctx, | ||
PermissionAccount, | ||
http.MethodGet, | ||
[]string{"v1", "mgmt", "linkaccounts"}, | ||
nil, | ||
input, | ||
&ans, | ||
) | ||
|
||
return ans, err | ||
} | ||
|
||
// Delete the given account. | ||
func (c *Client) DeleteAccount(ctx context.Context, input account.DeleteInput) error { | ||
c.Log(http.MethodDelete, "delete account: %s", input.AccountId) | ||
|
||
_, err := c.Communicate( | ||
ctx, | ||
PermissionAccount, | ||
http.MethodDelete, | ||
[]string{"v1", "mgmt", "linkaccounts", input.AccountId}, | ||
nil, | ||
nil, | ||
nil, | ||
) | ||
|
||
return err | ||
} |
Oops, something went wrong.