webhook

package
v2.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ResourceMarkdownDescription = `


# Webhook resource
Webhook resource can be used to create webhooks integrations in Port.

## Example Usage

` + "```hcl" + `
resource "port_blueprint" "author" {
    title = "Author"
    icon = "User"
    identifier = "author"
    properties = {
      string_props = {
        "name" = {
          type = "string"
          title = "Name"
        }
      }
    }
  }

  resource "port_blueprint" "team" {
    title = "Team"
    icon = "Team"
    identifier = "team"
    properties = {
      string_props = {
        "name" = {
          type = "string"
          title = "Team Name"
        }
      }
    }
  }

  resource "port_blueprint" "microservice" {
    title = "TF test microservice"
    icon = "Terraform"
    identifier = "microservice"
    properties = {
      string_props = {
        "url" = {
          type = "string"
          title = "URL"
        }
      }
    }
    relations = {
      "author" = {
        title = "Author"
        target = port_blueprint.author.identifier
      }
      "team" = {
        title = "Team"
        target = port_blueprint.team.identifier
      }
    }
  }

  resource "port_webhook" "create_pr" {
    identifier = "pr_webhook"
    title      = "Webhook with mixed relations"
    icon       = "Terraform"
    enabled    = true
    
    mappings = [
      {
        blueprint = port_blueprint.microservice.identifier
        operation = { "type" = "create" }
        filter    = ".headers.\"x-github-event\" == \"pull_request\""
        entity = {
          identifier = ".body.pull_request.id | tostring"
          title      = ".body.pull_request.title"
          properties = {
            url = ".body.pull_request.html_url"
          }
          relations = {
            # Complex object relation with search query
            author = jsonencode({
              combinator = "'and'",
              rules = [
                {
                  property = "'$identifier'"
                  operator = "'='"
                  value    = ".body.pull_request.user.login | tostring"
                }
              ]
            })
            
            # Simple string relation
            team = ".body.repository.owner.login | tostring"
          }
        }
      }
    ]
    
    depends_on = [
      port_blueprint.microservice,
      port_blueprint.author,
      port_blueprint.team
    ]
  }

  # Example with complex identifier using search query
  resource "port_webhook" "complex_identifier" {
    identifier = "complex_identifier_webhook"
    title      = "Webhook with complex identifier"
    icon       = "Terraform"
    enabled    = true
    
    mappings = [
      {
        blueprint = port_blueprint.microservice.identifier
        operation = { "type" = "create" }
        filter    = ".headers.\"x-github-event\" == \"push\""
        entity = {
          # Complex identifier using search query to find entity by ARN
          identifier = jsonencode({
            combinator = "'and'",
            rules = [
              {
                property = "'arn'"
                operator = "'='"
                value    = ".body.resources[0]"
              }
            ]
          })
          title      = ".body.repository.name"
          properties = {
            url = ".body.repository.html_url"
          }
        }
      }
    ]
    
    depends_on = [
      port_blueprint.microservice
    ]
  }
` + "\n```" + `

## Notes

- When using object format for relations, ` + "`combinator`, `property`" + ` and ` + "`operator`" + ` fields should be enclosed in single quotes, while ` + "`value`" + ` should not have quotes as it's a JQ expression. The single quotes are required because these fields contain literal string values that must be passed as-is to the Port API, whereas ` + "`value`" + ` contains a JQ expression that should be evaluated dynamically.
- The ` + "`identifier`" + ` field supports both simple JQ expressions (strings) and complex search query objects. When using search query objects, the structure must include ` + "`combinator`" + ` and ` + "`rules`" + ` fields, and each rule must have ` + "`property`" + `, ` + "`operator`" + `, and ` + "`value`" + ` fields.
- For all available operators, see the [Port comparison operators documentation](https://docs.port.io/search-and-query/comparison-operators).

`

Functions

func NewWebhookResource

func NewWebhookResource() resource.Resource

func WebhookMappingSchema

func WebhookMappingSchema() map[string]schema.Attribute

func WebhookSchema

func WebhookSchema() map[string]schema.Attribute

func WebhookSecuritySchema

func WebhookSecuritySchema() map[string]schema.Attribute

Types

type EntityModel

type EntityModel struct {
	Identifier types.String      `tfsdk:"identifier"`
	Title      types.String      `tfsdk:"title"`
	Icon       types.String      `tfsdk:"icon"`
	Team       types.String      `tfsdk:"team"`
	Properties map[string]string `tfsdk:"properties"`
	Relations  map[string]string `tfsdk:"relations"`
}

type MappingsModel

type MappingsModel struct {
	Blueprint    types.String    `tfsdk:"blueprint"`
	Filter       types.String    `tfsdk:"filter"`
	Operation    *OperationModel `tfsdk:"operation"`
	ItemsToParse types.String    `tfsdk:"items_to_parse"`
	Entity       *EntityModel    `tfsdk:"entity"`
}

type OperationModel added in v2.4.0

type OperationModel struct {
	Type             types.String `tfsdk:"type"`
	DeleteDependents types.Bool   `tfsdk:"delete_dependents"`
}

type SecurityModel

type SecurityModel struct {
	Secret                types.String `tfsdk:"secret"`
	SignatureHeaderName   types.String `tfsdk:"signature_header_name"`
	SignatureAlgorithm    types.String `tfsdk:"signature_algorithm"`
	SignaturePrefix       types.String `tfsdk:"signature_prefix"`
	RequestIdentifierPath types.String `tfsdk:"request_identifier_path"`
}

type WebhookModel

type WebhookModel struct {
	ID          types.String    `tfsdk:"id"`
	Icon        types.String    `tfsdk:"icon"`
	Identifier  types.String    `tfsdk:"identifier"`
	Title       types.String    `tfsdk:"title"`
	Description types.String    `tfsdk:"description"`
	Enabled     types.Bool      `tfsdk:"enabled"`
	WebhookKey  types.String    `tfsdk:"webhook_key"`
	Url         types.String    `tfsdk:"url"`
	Security    *SecurityModel  `tfsdk:"security"`
	Mappings    []MappingsModel `tfsdk:"mappings"`
	CreatedAt   types.String    `tfsdk:"created_at"`
	CreatedBy   types.String    `tfsdk:"created_by"`
	UpdatedAt   types.String    `tfsdk:"updated_at"`
	UpdatedBy   types.String    `tfsdk:"updated_by"`
}

type WebhookResource

type WebhookResource struct {
	// contains filtered or unexported fields
}

func (*WebhookResource) Configure

func (*WebhookResource) Create

func (*WebhookResource) Delete

func (*WebhookResource) ImportState

func (*WebhookResource) Metadata

func (*WebhookResource) Read

func (*WebhookResource) Schema

func (*WebhookResource) Update

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL