aggregation_properties

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AggregationPropertyResourceMarkdownDescription = `

# Aggregation Properties

This resource allows you to manage aggregation properties of a blueprint.

See the [Port documentation](https://docs.getport.io/build-your-software-catalog/define-your-data-model/setup-blueprint/properties/aggregation-properties/) for more information about aggregation properties.


Supported Methods:

- count_entities - Count the entities of the target blueprint
- average_entities - Average the entities of the target blueprint by time periods
- average_by_property - Calculate the average by property value of the target entities
- aggregate_by_property - Calculate the aggregate by property value of the target entities, such as sum, min, max, median

## Example Usage

Create a parent blueprint with a child blueprint and an aggregation property to count the parent kids:

` + "```hcl" + `

resource "port_blueprint" "parent_blueprint" {
  title       = "Parent Blueprint"
  icon        = "Terraform"
  identifier  = "parent"
  description = ""
  properties = {
    number_props = {
      "age" = {
        title = "Age"
      }
    }
  }
}

resource "port_blueprint" "child_blueprint" {
  title       = "Child Blueprint"
  icon        = "Terraform"
  identifier  = "child"
  description = ""
  properties = {
    number_props = {
      "age" = {
        title = "Age"
      }
    }
  }
  relations = {
    "parent" = {
      title  = "Parent"
      target = port_blueprint.parent_blueprint.identifier
    }
  }
}

resource "port_aggregation_properties" "parent_aggregation_properties" {
  blueprint_identifier        = port_blueprint.parent_blueprint.identifier
  properties = {
    "count_kids" = {
      target_blueprint_identifier = port_blueprint.child_blueprint.identifier
      title                       = "Count Kids"
      icon                        = "Terraform"
      description                 = "Count Kids"
      method                      = {
        count_entities = true
      }
    }
  }
}

` + "```" + `

Create a parent blueprint with a child blueprint and an aggregation property to calculate the average avg of the parent kids age:

` + "```hcl" + `

resource "port_blueprint" "parent_blueprint" {
  title       = "Parent Blueprint"
  icon        = "Terraform"
  identifier  = "parent"
  description = ""
  properties = {
    number_props = {
      "age" = {
        title = "Age"
      }
    }
  }
}

resource "port_blueprint" "child_blueprint" {
  title       = "Child Blueprint"
  icon        = "Terraform"
  identifier  = "child"
  description = ""
  properties = {
    number_props = {
      "age" = {
        title = "Age"
      }
    }
  }
  relations = {
    "parent" = {
      title  = "Parent"
      target = port_blueprint.parent_blueprint.identifier
    }
  }
}

resource "port_aggregation_properties" "parent_aggregation_properties" {
  blueprint_identifier = port_blueprint.parent_blueprint.identifier
  properties           = {
    average_kids_age = {
      target_blueprint_identifier = port_blueprint.child_blueprint.identifier
      title                       = "Average Kids Age"
      icon                        = "Terraform"
      description                 = "Average Kids Age"
      method                      = {
        average_by_property = {
          average_of      = "total"
          measure_time_by = "$createdAt"
          property        = "age"
        }
      }
    }
  }
}


` + "```" + `

Create a repository blueprint and a pull request blueprint and an aggregation property to calculate the average of pull requests created per day:

` + "```hcl" + `

resource "port_blueprint" "repository_blueprint" {
  title       = "Repository Blueprint"
  icon        = "Terraform"
  identifier  = "repository"
  description = ""
}

resource "port_blueprint" "pull_request_blueprint" {
  title       = "Pull Request Blueprint"
  icon        = "Terraform"
  identifier  = "pull_request"
  description = ""
  properties = {
    string_props = {
      "status" = {
        title = "Status"
      }
    }
  }
  relations = {
    "repository" = {
      title  = "Repository"
      target = port_blueprint.repository_blueprint.identifier
    }
  }
}

resource "port_aggregation_properties" "repository_aggregation_properties" {
  blueprint_identifier = port_blueprint.repository_blueprint.identifier
  properties           = {
    "pull_requests_per_day" = {
      target_blueprint_identifier = port_blueprint.pull_request_blueprint.identifier
      title                       = "Pull Requests Per Day"
      icon                        = "Terraform"
      description                 = "Pull Requests Per Day"
      method                      = {
        average_entities = {
          average_of      = "day"
          measure_time_by = "$createdAt"
        }
      }
    }
  }
}
  
` + "```" + `

Create a repository blueprint and a pull request blueprint and an aggregation property to calculate the average of fix pull request per month:

To do that we will add a query to the aggregation property to filter only pull requests with fixed title:

` + "```hcl" + `

resource "port_blueprint" "repository_blueprint" {
  title       = "Repository Blueprint"
  icon        = "Terraform"
  identifier  = "repository"
  description = ""
}

resource "port_blueprint" "pull_request_blueprint" {
  title       = "Pull Request Blueprint"
  icon        = "Terraform"
  identifier  = "pull_request"
  description = ""
  properties = {
    string_props = {
      "status" = {
        title = "Status"
      }
    }
  }
  relations = {
    "repository" = {
      title  = "Repository"
      target = port_blueprint.repository_blueprint.identifier
    }
  }
}

resource "port_aggregation_properties" "repository_aggregation_properties" {
  blueprint_identifier = port_blueprint.repository_blueprint.identifier
  properties           = {
    "fix_pull_requests_count" = {
      target_blueprint_identifier = port_blueprint.pull_request_blueprint.identifier
      title                       = "Pull Requests Per Day"
      icon                        = "Terraform"
      description                 = "Pull Requests Per Day"
      method                      = {
        average_entities = {
          average_of      = "month"
          measure_time_by = "$createdAt"
        }
      }
      query = jsonencode(
        {
          "combinator" : "and",
          "rules" : [
            {
              "property" : "$title",
              "operator" : "ContainsAny",
              "value" : ["fix", "fixed", "fixing", "Fix"]
            }
          ]
        }
      )
    }
  }
}

` + "```" + `


Create multiple aggregation properties in one resource:

` + "```hcl" + `

resource "port_blueprint" "repository_blueprint" {
  title       = "Repository Blueprint"
  icon        = "Terraform"
  identifier  = "repository"
  description = ""
}

resource "port_blueprint" "pull_request_blueprint" {
  title       = "Pull Request Blueprint"
  icon        = "Terraform"
  identifier  = "pull_request"
  description = ""
  properties = {
    string_props = {
      "status" = {
        title = "Status"
      }
    }
  }
  relations = {
    "repository" = {
      title  = "Repository"
      target = port_blueprint.repository_blueprint.identifier
    }
  }
}

resource "port_aggregation_properties" "repository_aggregation_properties" {
  blueprint_identifier = port_blueprint.repository_blueprint.identifier
  properties           = {
    "pull_requests_per_day" = {
      target_blueprint_identifier = port_blueprint.pull_request_blueprint.identifier
      title                       = "Pull Requests Per Day"
      icon                        = "Terraform"
      description                 = "Pull Requests Per Day"
      method                      = {
        average_entities = {
          average_of      = "day"
          measure_time_by = "$createdAt"
        }
      }
    }
    "overall_pull_requests_count" = {
      target_blueprint_identifier = port_blueprint.pull_request_blueprint.identifier
      title                       = "Overall Pull Requests Count"
      icon                        = "Terraform"
      description                 = "Overall Pull Requests Count"
      method                      = {
        count_entities = true
      }
    }
  }
}

` + "```" + ``

Functions

func AggregationPropertiesSchema

func AggregationPropertiesSchema() map[string]schema.Attribute

func AggregationPropertySchema

func AggregationPropertySchema() schema.Attribute

func NewAggregationPropertiesResource

func NewAggregationPropertiesResource() resource.Resource

Types

type AggregateByPropertyModel

type AggregateByPropertyModel struct {
	Func     types.String `tfsdk:"func"`
	Property types.String `tfsdk:"property"`
}

type AggregationMethodsModel

type AggregationMethodsModel struct {
	CountEntities       types.Bool                `tfsdk:"count_entities"`
	AverageEntities     *AverageEntitiesModel     `tfsdk:"average_entities"`
	AverageByProperty   *AverageByProperty        `tfsdk:"average_by_property"`
	AggregateByProperty *AggregateByPropertyModel `tfsdk:"aggregate_by_property"`
}

type AggregationPropertiesModel

type AggregationPropertiesModel struct {
	ID                  types.String                         `tfsdk:"id"`
	BlueprintIdentifier types.String                         `tfsdk:"blueprint_identifier"`
	Properties          map[string]*AggregationPropertyModel `tfsdk:"properties"`
}

type AggregationPropertiesResource

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

func (*AggregationPropertiesResource) Configure

func (*AggregationPropertiesResource) Create

func (*AggregationPropertiesResource) Delete

func (*AggregationPropertiesResource) ImportState

func (*AggregationPropertiesResource) Metadata

func (*AggregationPropertiesResource) Read

func (*AggregationPropertiesResource) Schema

func (*AggregationPropertiesResource) Update

type AggregationPropertyModel

type AggregationPropertyModel struct {
	Title                     types.String             `tfsdk:"title"`
	Icon                      types.String             `tfsdk:"icon"`
	Description               types.String             `tfsdk:"description"`
	TargetBlueprintIdentifier types.String             `tfsdk:"target_blueprint_identifier"`
	Method                    *AggregationMethodsModel `tfsdk:"method"`
	Query                     types.String             `tfsdk:"query"`
}

type AverageByProperty

type AverageByProperty struct {
	MeasureTimeBy types.String `tfsdk:"measure_time_by"`
	AverageOf     types.String `tfsdk:"average_of"`
	Property      types.String `tfsdk:"property"`
}

type AverageEntitiesModel

type AverageEntitiesModel struct {
	AverageOf     types.String `tfsdk:"average_of"`
	MeasureTimeBy types.String `tfsdk:"measure_time_by"`
}

Jump to

Keyboard shortcuts

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