Documentation ¶
Index ¶
- Constants
- Variables
- func AddConfigurationAttributeError(resp *provider.ConfigureResponse, name, envName string, isUnknown bool)
- func DeepEqualJSONByte(a, b []byte) (bool, error)
- func IsValueProvided(value attr.Value) bool
- func New(version string) func() provider.Provider
- func NewGroupResource() resource.Resource
- func NewHostResource() resource.Resource
- func NewInventoryDataSource() datasource.DataSource
- func NewInventoryResource() resource.Resource
- func NewJobResource() resource.Resource
- func ParseAAPCustomStringValue(variables string) customtypes.AAPCustomStringValue
- func ParseNormalizedValue(variables string) jsontypes.Normalized
- func ParseStringValue(description string) types.String
- func ValidateResponse(resp *http.Response, body []byte, err error, expected_statuses []int) diag.Diagnostics
- type AAPClient
- type GroupAPIModel
- type GroupResource
- func (r *GroupResource) Configure(_ context.Context, req resource.ConfigureRequest, ...)
- func (r *GroupResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r *GroupResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r *GroupResource) Metadata(_ context.Context, req resource.MetadataRequest, ...)
- func (r *GroupResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r *GroupResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r *GroupResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- type GroupResourceModel
- type HostAPIModel
- type HostResource
- func (r *HostResource) AssociateGroups(ctx context.Context, data []int64, url string, args ...bool) diag.Diagnostics
- func (r *HostResource) Configure(_ context.Context, req resource.ConfigureRequest, ...)
- func (r *HostResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r *HostResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r *HostResource) HandleGroupAssociation(ctx context.Context, data HostResourceModel) diag.Diagnostics
- func (r *HostResource) Metadata(_ context.Context, req resource.MetadataRequest, ...)
- func (r *HostResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r *HostResource) ReadAssociatedGroups(data HostResourceModel) ([]int64, diag.Diagnostics)
- func (r *HostResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r *HostResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- type HostResourceModel
- type InventoryAPIModel
- type InventoryDataSource
- func (d *InventoryDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, ...)
- func (d *InventoryDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, ...)
- func (d *InventoryDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse)
- func (d *InventoryDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse)
- type InventoryDataSourceModel
- type InventoryResource
- func (r *InventoryResource) Configure(_ context.Context, req resource.ConfigureRequest, ...)
- func (r *InventoryResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r *InventoryResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r *InventoryResource) Metadata(_ context.Context, req resource.MetadataRequest, ...)
- func (r *InventoryResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r *InventoryResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r *InventoryResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- type JobAPIModel
- type JobResource
- func (r *JobResource) Configure(_ context.Context, req resource.ConfigureRequest, ...)
- func (r *JobResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r JobResource) Delete(_ context.Context, _ resource.DeleteRequest, _ *resource.DeleteResponse)
- func (r *JobResource) LaunchJob(data *JobResourceModel) diag.Diagnostics
- func (r *JobResource) Metadata(_ context.Context, req resource.MetadataRequest, ...)
- func (r *JobResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r *JobResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r *JobResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- type JobResourceModel
- func (r *JobResourceModel) CreateRequestBody() ([]byte, diag.Diagnostics)
- func (r *JobResourceModel) GetTemplateID() string
- func (r *JobResourceModel) ParseHttpResponse(body []byte) diag.Diagnostics
- func (r *JobResourceModel) ParseIgnoredFields(ignoredFields map[string]interface{}) (diags diag.Diagnostics)
- type MockHTTPClient
- func (c *MockHTTPClient) Create(path string, data io.Reader) ([]byte, diag.Diagnostics)
- func (c *MockHTTPClient) Delete(path string) ([]byte, diag.Diagnostics)
- func (c *MockHTTPClient) Get(path string) ([]byte, diag.Diagnostics)
- func (c *MockHTTPClient) Update(path string, data io.Reader) ([]byte, diag.Diagnostics)
- type ProviderHTTPClient
Constants ¶
const ( DefaultTimeOut = 5 // Default http session timeout DefaultInsecureSkipVerify = false // Default value for insecure skip verify )
Variables ¶
var GroupResponse1 = map[string]string{
"description": "",
"inventory": "1",
"name": "Group1",
}
var GroupResponse2 = map[string]string{
"description": "Updated group",
"inventory": "1",
"name": "Group1",
}
var GroupResponse3 = map[string]string{
"description": "",
"inventory": "3",
"name": "Group1",
"variables": "{\"ansible_network_os\": \"ios\"}",
}
var JobResponse1 = map[string]string{
"status": "running",
"type": "check",
}
var JobResponse2 = map[string]string{
"status": "pending",
"playbook": "ansible_aws.yaml",
}
var JobResponse3 = map[string]string{
"status": "complete",
"execution_environment": "3",
}
var MockConfig = map[string]map[string]string{ "/api/v2/job_templates/1/launch/": JobResponse1, "/api/v2/job_templates/2/launch/": JobResponse2, "/api/v2/jobs/1/": JobResponse1, "/api/v2/jobs/2/": JobResponse3, "/api/v2/groups/": GroupResponse1, "/api/v2/groups/1/": GroupResponse2, "/api/v2/groups/2/": GroupResponse3, }
Functions ¶
func AddConfigurationAttributeError ¶
func AddConfigurationAttributeError(resp *provider.ConfigureResponse, name, envName string, isUnknown bool)
func DeepEqualJSONByte ¶
DeepEqualJSONByte compares the JSON in two byte slices.
func IsValueProvided ¶
func NewGroupResource ¶
NewGroupResource is a helper function to simplify the provider implementation.
func NewHostResource ¶
NewHostResource is a helper function to simplify the provider implementation.
func NewInventoryDataSource ¶
func NewInventoryDataSource() datasource.DataSource
NewInventoryDataSource is a helper function to simplify the provider implementation.
func NewInventoryResource ¶
NewInventoryResource is a helper function to simplify the provider implementation.
func NewJobResource ¶
NewJobResource is a helper function to simplify the provider implementation.
func ParseAAPCustomStringValue ¶
func ParseAAPCustomStringValue(variables string) customtypes.AAPCustomStringValue
func ParseNormalizedValue ¶
func ParseNormalizedValue(variables string) jsontypes.Normalized
func ParseStringValue ¶
func ValidateResponse ¶
Types ¶
type AAPClient ¶
type AAPClient struct { HostURL string Username *string Password *string // contains filtered or unexported fields }
Client -
func NewClient ¶
func NewClient(host string, username *string, password *string, insecureSkipVerify bool, timeout int64) (*AAPClient, error)
NewClient - create new AAPClient instance
func (*AAPClient) Create ¶
Create sends a POST request with the provided data to the provided path, checks for errors, and returns the response body with any errors as diagnostics.
func (*AAPClient) Delete ¶
func (c *AAPClient) Delete(path string) ([]byte, diag.Diagnostics)
Delete sends a DELETE request to the provided path, checks for errors, and returns any errors as diagnostics.
type GroupAPIModel ¶
type GroupAPIModel struct { InventoryId int64 `json:"inventory"` Name string `json:"name"` Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` Variables string `json:"variables,omitempty"` Id int64 `json:"id,omitempty"` }
Group AAP API model
type GroupResource ¶
type GroupResource struct {
// contains filtered or unexported fields
}
GroupResource is the resource implementation.
func (*GroupResource) Configure ¶
func (r *GroupResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
Configure adds the provider configured client to the resource
func (*GroupResource) Create ¶
func (r *GroupResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
Create creates the group resource and sets the Terraform state on success.
func (*GroupResource) Delete ¶
func (r *GroupResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
Delete deletes the group resource.
func (*GroupResource) Metadata ¶
func (r *GroupResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
Metadata returns the resource type name.
func (*GroupResource) Read ¶
func (r *GroupResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
Read refreshes the Terraform state with the latest group data.
func (*GroupResource) Schema ¶
func (r *GroupResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
Schema defines the schema for the group resource.
func (*GroupResource) Update ¶
func (r *GroupResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
Update updates the group resource and sets the updated Terraform state on success.
type GroupResourceModel ¶
type GroupResourceModel struct { InventoryId types.Int64 `tfsdk:"inventory_id"` Name types.String `tfsdk:"name"` Description types.String `tfsdk:"description"` URL types.String `tfsdk:"url"` Variables customtypes.AAPCustomStringValue `tfsdk:"variables"` Id types.Int64 `tfsdk:"id"` }
GroupResourceModel maps the group resource schema to a Go struct
func (*GroupResourceModel) CreateRequestBody ¶
func (r *GroupResourceModel) CreateRequestBody() ([]byte, diag.Diagnostics)
CreateRequestBody creates a JSON encoded request body from the group resource data
func (*GroupResourceModel) ParseHttpResponse ¶
func (r *GroupResourceModel) ParseHttpResponse(body []byte) diag.Diagnostics
ParseHttpResponse updates the group resource data from an AAP API response
type HostAPIModel ¶
type HostAPIModel struct { InventoryId int64 `json:"inventory"` Name string `json:"name"` Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` Variables string `json:"variables,omitempty"` Enabled bool `json:"enabled"` Id int64 `json:"id,omitempty"` }
Host AAP API model
type HostResource ¶
type HostResource struct {
// contains filtered or unexported fields
}
HostResource is the resource implementation.
func (*HostResource) AssociateGroups ¶
func (r *HostResource) AssociateGroups(ctx context.Context, data []int64, url string, args ...bool) diag.Diagnostics
func (*HostResource) Configure ¶
func (r *HostResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
Configure adds the provider configured client to the resource
func (*HostResource) Create ¶
func (r *HostResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
Create creates the host resource and sets the Terraform state on success.
func (*HostResource) Delete ¶
func (r *HostResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
Delete deletes the host resource.
func (*HostResource) HandleGroupAssociation ¶
func (r *HostResource) HandleGroupAssociation(ctx context.Context, data HostResourceModel) diag.Diagnostics
func (*HostResource) Metadata ¶
func (r *HostResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
Metadata returns the resource type name.
func (*HostResource) Read ¶
func (r *HostResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
Read refreshes the Terraform state with the latest host data.
func (*HostResource) ReadAssociatedGroups ¶
func (r *HostResource) ReadAssociatedGroups(data HostResourceModel) ([]int64, diag.Diagnostics)
func (*HostResource) Schema ¶
func (r *HostResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
Schema defines the schema for the host resource.
func (*HostResource) Update ¶
func (r *HostResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
Update updates the host resource and sets the updated Terraform state on success.
type HostResourceModel ¶
type HostResourceModel struct { InventoryId types.Int64 `tfsdk:"inventory_id"` Name types.String `tfsdk:"name"` URL types.String `tfsdk:"url"` Description types.String `tfsdk:"description"` Variables customtypes.AAPCustomStringValue `tfsdk:"variables"` Groups types.Set `tfsdk:"groups"` Enabled types.Bool `tfsdk:"enabled"` Id types.Int64 `tfsdk:"id"` }
HostResourceModel maps the host resource schema to a Go struct
func (*HostResourceModel) CreateRequestBody ¶
func (r *HostResourceModel) CreateRequestBody() ([]byte, diag.Diagnostics)
CreateRequestBody creates a JSON encoded request body from the host resource data
func (*HostResourceModel) ParseHttpResponse ¶
func (r *HostResourceModel) ParseHttpResponse(body []byte) diag.Diagnostics
ParseHttpResponse updates the host resource data from an AAP API response
func (*HostResourceModel) UpdateStateWithGroups ¶
func (r *HostResourceModel) UpdateStateWithGroups(ctx context.Context, groups []int64) diag.Diagnostics
type InventoryAPIModel ¶
type InventoryAPIModel struct { Id int64 `json:"id,omitempty"` Organization int64 `json:"organization"` Url string `json:"url,omitempty"` Name string `json:"name"` Description string `json:"description,omitempty"` Variables string `json:"variables,omitempty"` }
Inventory AAP API model
type InventoryDataSource ¶
type InventoryDataSource struct {
// contains filtered or unexported fields
}
inventoryDataSource is the data source implementation.
func (*InventoryDataSource) Configure ¶
func (d *InventoryDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse)
Configure adds the provider configured client to the data source.
func (*InventoryDataSource) Metadata ¶
func (d *InventoryDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse)
Metadata returns the data source type name.
func (*InventoryDataSource) Read ¶
func (d *InventoryDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse)
Read refreshes the Terraform state with the latest data.
func (*InventoryDataSource) Schema ¶
func (d *InventoryDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse)
Schema defines the schema for the data source.
type InventoryDataSourceModel ¶
type InventoryDataSourceModel struct { Id types.Int64 `tfsdk:"id"` Organization types.Int64 `tfsdk:"organization"` Url types.String `tfsdk:"url"` Name types.String `tfsdk:"name"` Description types.String `tfsdk:"description"` Variables customtypes.AAPCustomStringValue `tfsdk:"variables"` }
inventoryDataSourceModel maps the data source schema data.
func (*InventoryDataSourceModel) ParseHttpResponse ¶
func (d *InventoryDataSourceModel) ParseHttpResponse(body []byte) diag.Diagnostics
type InventoryResource ¶
type InventoryResource struct {
// contains filtered or unexported fields
}
InventoryResource is the resource implementation.
func (*InventoryResource) Configure ¶
func (r *InventoryResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
Configure adds the provider configured client to the resource.
func (*InventoryResource) Create ¶
func (r *InventoryResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
Create creates the inventory resource and sets the Terraform state on success.
func (*InventoryResource) Delete ¶
func (r *InventoryResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
Delete deletes the inventory resource.
func (*InventoryResource) Metadata ¶
func (r *InventoryResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
Metadata returns the resource type name.
func (*InventoryResource) Read ¶
func (r *InventoryResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
Read refreshes the Terraform state with the latest inventory data.
func (*InventoryResource) Schema ¶
func (r *InventoryResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
Schema defines the schema for the resource.
func (*InventoryResource) Update ¶
func (r *InventoryResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
Update updates the inventory resource and sets the updated Terraform state on success.
type JobAPIModel ¶
type JobAPIModel struct { TemplateID int64 `json:"job_template,omitempty"` Type string `json:"job_type,omitempty"` URL string `json:"url,omitempty"` Status string `json:"status,omitempty"` Inventory int64 `json:"inventory,omitempty"` ExtraVars string `json:"extra_vars,omitempty"` IgnoredFields map[string]interface{} `json:"ignored_fields,omitempty"` }
Job AAP API model
type JobResource ¶
type JobResource struct {
// contains filtered or unexported fields
}
JobResource is the resource implementation.
func (*JobResource) Configure ¶
func (r *JobResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
Configure adds the provider configured client to the data source.
func (*JobResource) Create ¶
func (r *JobResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
func (JobResource) Delete ¶
func (r JobResource) Delete(_ context.Context, _ resource.DeleteRequest, _ *resource.DeleteResponse)
func (*JobResource) LaunchJob ¶
func (r *JobResource) LaunchJob(data *JobResourceModel) diag.Diagnostics
func (*JobResource) Metadata ¶
func (r *JobResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
Metadata returns the resource type name.
func (*JobResource) Read ¶
func (r *JobResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
func (*JobResource) Schema ¶
func (r *JobResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
Schema defines the schema for the jobresource.
func (*JobResource) Update ¶
func (r *JobResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
type JobResourceModel ¶
type JobResourceModel struct { TemplateID types.Int64 `tfsdk:"job_template_id"` Type types.String `tfsdk:"job_type"` URL types.String `tfsdk:"url"` Status types.String `tfsdk:"status"` InventoryID types.Int64 `tfsdk:"inventory_id"` ExtraVars customtypes.AAPCustomStringValue `tfsdk:"extra_vars"` IgnoredFields types.List `tfsdk:"ignored_fields"` Triggers types.Map `tfsdk:"triggers"` }
JobResourceModel maps the resource schema data.
func (*JobResourceModel) CreateRequestBody ¶
func (r *JobResourceModel) CreateRequestBody() ([]byte, diag.Diagnostics)
CreateRequestBody creates a JSON encoded request body from the job resource data
func (*JobResourceModel) GetTemplateID ¶
func (r *JobResourceModel) GetTemplateID() string
func (*JobResourceModel) ParseHttpResponse ¶
func (r *JobResourceModel) ParseHttpResponse(body []byte) diag.Diagnostics
ParseHttpResponse updates the job resource data from an AAP API response
func (*JobResourceModel) ParseIgnoredFields ¶
func (r *JobResourceModel) ParseIgnoredFields(ignoredFields map[string]interface{}) (diags diag.Diagnostics)
type MockHTTPClient ¶
type MockHTTPClient struct {
// contains filtered or unexported fields
}
func NewMockHTTPClient ¶
func NewMockHTTPClient(methods []string, httpCode int) *MockHTTPClient
func (*MockHTTPClient) Create ¶
func (c *MockHTTPClient) Create(path string, data io.Reader) ([]byte, diag.Diagnostics)
func (*MockHTTPClient) Delete ¶
func (c *MockHTTPClient) Delete(path string) ([]byte, diag.Diagnostics)
func (*MockHTTPClient) Get ¶
func (c *MockHTTPClient) Get(path string) ([]byte, diag.Diagnostics)
func (*MockHTTPClient) Update ¶
func (c *MockHTTPClient) Update(path string, data io.Reader) ([]byte, diag.Diagnostics)
type ProviderHTTPClient ¶
type ProviderHTTPClient interface { Create(path string, data io.Reader) ([]byte, diag.Diagnostics) Get(path string) ([]byte, diag.Diagnostics) Update(path string, data io.Reader) ([]byte, diag.Diagnostics) Delete(path string) ([]byte, diag.Diagnostics) // contains filtered or unexported methods }
Provider Http Client interface (will be useful for unit tests)