 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Variables
- func AggregationPropertiesSchema() map[string]schema.Attribute
- func AggregationPropertySchema() schema.Attribute
- func NewAggregationPropertiesResource() resource.Resource
- type AggregateByPropertyModel
- type AggregationMethodsModel
- type AggregationPropertiesModel
- type AggregationPropertiesResource
- func (r *AggregationPropertiesResource) Configure(ctx context.Context, req resource.ConfigureRequest, ...)
- func (r *AggregationPropertiesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r *AggregationPropertiesResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r *AggregationPropertiesResource) ImportState(ctx context.Context, req resource.ImportStateRequest, ...)
- func (r *AggregationPropertiesResource) Metadata(ctx context.Context, req resource.MetadataRequest, ...)
- func (r *AggregationPropertiesResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r *AggregationPropertiesResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r *AggregationPropertiesResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
 
- type AggregationPropertyModel
- type AggregationPropertyPathFilterModel
- type AverageByProperty
- type AverageEntitiesModel
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/customize-integrations/configure-data-model/setup-blueprint/properties/aggregation-property/) 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 ¶
Types ¶
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 AggregationPropertiesResource ¶
type AggregationPropertiesResource struct {
	// contains filtered or unexported fields
}
    func (*AggregationPropertiesResource) Configure ¶
func (r *AggregationPropertiesResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
func (*AggregationPropertiesResource) Create ¶
func (r *AggregationPropertiesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
func (*AggregationPropertiesResource) Delete ¶
func (r *AggregationPropertiesResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
func (*AggregationPropertiesResource) ImportState ¶
func (r *AggregationPropertiesResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse)
func (*AggregationPropertiesResource) Metadata ¶
func (r *AggregationPropertiesResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
func (*AggregationPropertiesResource) Read ¶
func (r *AggregationPropertiesResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
func (*AggregationPropertiesResource) Schema ¶
func (r *AggregationPropertiesResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse)
func (*AggregationPropertiesResource) Update ¶
func (r *AggregationPropertiesResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
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"`
	PathFilter                []AggregationPropertyPathFilterModel `tfsdk:"path_filter"`
}
    type AggregationPropertyPathFilterModel ¶ added in v2.12.0
type AverageByProperty ¶
 Click to show internal directories. 
   Click to hide internal directories.