-
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
Showing
8 changed files
with
581 additions
and
2 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,53 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "port-labs_action Resource - terraform-provider-port-labs" | ||
subcategory: "" | ||
description: |- | ||
Port action | ||
--- | ||
|
||
# port-labs_action (Resource) | ||
|
||
Port action | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `blueprint_identifier` (String) The identifier of the blueprint | ||
- `identifier` (String) The identifier of the action | ||
- `invocation_method` (String) The methods the action is dispatched in, currently only supports KAFKA | ||
- `title` (String) The display name of the action | ||
- `trigger` (String) The type of the action, one of CREATE, DAY-2, DELETE | ||
|
||
### Optional | ||
|
||
- `description` (String) The description of the action | ||
- `icon` (String) The icon of the action | ||
- `required_properties` (Set of String) The required properties of the action | ||
- `user_properties` (Block Set) The input properties of the action (see [below for nested schema](#nestedblock--user_properties)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
<a id="nestedblock--user_properties"></a> | ||
### Nested Schema for `user_properties` | ||
|
||
Required: | ||
|
||
- `identifier` (String) The identifier of the property | ||
- `title` (String) A nicely written name for the property | ||
- `type` (String) The type of the property | ||
|
||
Optional: | ||
|
||
- `default` (String) A default value for this property in case an entity is created without explicitly providing a value. | ||
- `description` (String) A description of the property. This value is visible to users when hovering on the info icon in the UI. It provides detailed information about the use of a specific property. | ||
- `format` (String) A specific data format to pair with some of the available types | ||
- `pattern` (String) A regular expression (regex) pattern to specify the set of allowed values for the property | ||
|
||
|
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,17 @@ | ||
resource "port-labs_action" "restart_microservice" { | ||
title = "Restart microservice" | ||
icon = "Terraform" | ||
identifier = "restart-micrservice" | ||
blueprint_identifier = port-labs_blueprint.microservice.identifier | ||
trigger = "DAY-2" | ||
invocation_method = "KAFKA" | ||
user_properties { | ||
identifier = "webhook_url" | ||
type = "string" | ||
title = "Webhook URL" | ||
description = "Webhook URL to send the request to" | ||
format = "url" | ||
default = "https://example.com" | ||
pattern = "^https://.*" | ||
} | ||
} |
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,91 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func (c *PortClient) ReadAction(ctx context.Context, blueprintID, id string) (*Action, error) { | ||
pb := &PortBody{} | ||
url := "v1/blueprints/{blueprint_identifier}/actions/{action_identifier}" | ||
resp, err := c.Client.R(). | ||
SetContext(ctx). | ||
SetHeader("Accept", "application/json"). | ||
SetResult(pb). | ||
SetPathParam("blueprint_identifier", blueprintID). | ||
SetPathParam("action_identifier", id). | ||
Get(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if !pb.OK { | ||
return nil, fmt.Errorf("failed to read action, got: %s", resp.Body()) | ||
} | ||
return &pb.Action, nil | ||
} | ||
|
||
func (c *PortClient) CreateAction(ctx context.Context, blueprintID string, action *Action) (*Action, error) { | ||
url := "v1/blueprints/{blueprint_identifier}/actions" | ||
resp, err := c.Client.R(). | ||
SetBody(action). | ||
SetPathParam("blueprint_identifier", blueprintID). | ||
SetContext(ctx). | ||
Post(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var pb PortBody | ||
err = json.Unmarshal(resp.Body(), &pb) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if !pb.OK { | ||
return nil, fmt.Errorf("failed to create action, got: %s", resp.Body()) | ||
} | ||
return &pb.Action, nil | ||
} | ||
|
||
func (c *PortClient) UpdateAction(ctx context.Context, blueprintID, actionID string, action *Action) (*Action, error) { | ||
url := "v1/blueprints/{blueprint_identifier}/actions/{action_identifier}" | ||
resp, err := c.Client.R(). | ||
SetBody(action). | ||
SetContext(ctx). | ||
SetPathParam("blueprint_identifier", blueprintID). | ||
SetPathParam("action_identifier", actionID). | ||
Put(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var pb PortBody | ||
err = json.Unmarshal(resp.Body(), &pb) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if !pb.OK { | ||
return nil, fmt.Errorf("failed to create action, got: %s", resp.Body()) | ||
} | ||
return &pb.Action, nil | ||
} | ||
|
||
func (c *PortClient) DeleteAction(ctx context.Context, blueprintID, actionID string) error { | ||
url := "v1/blueprints/{blueprint_identifier}/actions/{action_identifier}" | ||
resp, err := c.Client.R(). | ||
SetContext(ctx). | ||
SetHeader("Accept", "application/json"). | ||
SetPathParam("blueprint_identifier", blueprintID). | ||
SetPathParam("action_identifier", actionID). | ||
Delete(url) | ||
if err != nil { | ||
return err | ||
} | ||
responseBody := make(map[string]interface{}) | ||
err = json.Unmarshal(resp.Body(), &responseBody) | ||
if err != nil { | ||
return err | ||
} | ||
if !(responseBody["ok"].(bool)) { | ||
return fmt.Errorf("failed to delete action. got:\n%s", string(resp.Body())) | ||
} | ||
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
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
Oops, something went wrong.