-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Data Source: azurerm_scheduler_job_collection
#990
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c275d93
Added new data source scheduler_job_collection
katbyte 95f95ed
Minor change to tests
katbyte 0c83795
Merge remote-tracking branch 'origin/master' into f-ds-scheduler_job_…
katbyte 6ad99fc
Updated the azurerm_scheduler_job_collection data source with request…
katbyte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package azurerm | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform/helper/schema" | ||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" | ||
) | ||
|
||
func dataSourceArmSchedulerJobCollection() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceArmSchedulerJobCollectionRead, | ||
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, | ||
}, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
|
||
"location": locationForDataSourceSchema(), | ||
|
||
"resource_group_name": resourceGroupNameForDataSourceSchema(), | ||
|
||
"tags": tagsForDataSourceSchema(), | ||
|
||
"sku": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"state": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
"quota": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
|
||
//max_job_occurrence doesn't seem to do anything and always remains empty | ||
|
||
"max_job_count": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
|
||
"max_recurrence_frequency": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
|
||
//this is MaxRecurrance.Interval, property is named this as the documentation in the api states: | ||
// Gets or sets the interval between retries. | ||
"max_retry_interval": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceArmSchedulerJobCollectionRead(d *schema.ResourceData, meta interface{}) error { | ||
client := meta.(*ArmClient).schedulerJobCollectionsClient | ||
ctx := meta.(*ArmClient).StopContext | ||
|
||
resourceGroup := d.Get("resource_group_name").(string) | ||
name := d.Get("name").(string) | ||
|
||
collection, err := client.Get(ctx, resourceGroup, name) | ||
if err != nil { | ||
if utils.ResponseWasNotFound(collection.Response) { | ||
d.SetId("") | ||
return nil | ||
} | ||
|
||
return fmt.Errorf("Error making Read request on Scheduler Job Collection %q (Resource Group %q): %+v", name, resourceGroup, err) | ||
} | ||
|
||
d.SetId(*collection.ID) | ||
|
||
//standard properties | ||
d.Set("name", collection.Name) | ||
d.Set("location", azureRMNormalizeLocation(*collection.Location)) | ||
d.Set("resource_group_name", resourceGroup) | ||
flattenAndSetTags(d, collection.Tags) | ||
|
||
//resource specific | ||
if properties := collection.Properties; properties != nil { | ||
if sku := properties.Sku; sku != nil { | ||
d.Set("sku", sku.Name) | ||
} | ||
d.Set("state", string(properties.State)) | ||
|
||
if err := d.Set("quota", flattenAzureArmSchedulerJobCollectionQuota(properties.Quota)); err != nil { | ||
return fmt.Errorf("Error flattening quota for Job Collection %q (Resource Group %q): %+v", collection.Name, resourceGroup, err) | ||
} | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package azurerm | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/acctest" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceAzureRMSchedulerJobCollection_basic(t *testing.T) { | ||
dataSourceName := "data.azurerm_scheduler_job_collection.test" | ||
ri := acctest.RandInt() | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceSchedulerJobCollection_basic(ri, testLocation()), | ||
Check: checkAccAzureRMSchedulerJobCollection_basic(dataSourceName), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccDataSourceAzureRMSchedulerJobCollection_complete(t *testing.T) { | ||
dataSourceName := "data.azurerm_scheduler_job_collection.test" | ||
ri := acctest.RandInt() | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceSchedulerJobCollection_complete(ri, testLocation()), | ||
Check: checkAccAzureRMSchedulerJobCollection_complete(dataSourceName), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceSchedulerJobCollection_basic(rInt int, location string) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
||
data "azurerm_scheduler_job_collection" "test" { | ||
name = "${azurerm_scheduler_job_collection.test.name}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
} | ||
`, testAccAzureRMSchedulerJobCollection_basic(rInt, location, "")) | ||
} | ||
|
||
func testAccDataSourceSchedulerJobCollection_complete(rInt int, location string) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
||
data "azurerm_scheduler_job_collection" "test" { | ||
name = "${azurerm_scheduler_job_collection.test.name}" | ||
resource_group_name = "${azurerm_resource_group.test.name}" | ||
} | ||
`, testAccAzureRMSchedulerJobCollection_complete(rInt, location)) | ||
} |
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
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
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,56 @@ | ||
--- | ||
layout: "azurerm" | ||
page_title: "Azure Resource Manager: azurerm_scheduler_job_collection" | ||
sidebar_current: "docs-azurerm-datasource-scheduler_job_collection" | ||
description: |- | ||
Get information about the specified scheduler job collection. | ||
--- | ||
|
||
# Data Source: azurerm_scheduler_job_collection | ||
|
||
Use this data source to access the properties of an Azure scheduler job collection. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "azurerm_scheduler_job_collection" "test" { | ||
name = "tfex-job-collection" | ||
resource_group_name = "tfex-job-collection-rg" | ||
} | ||
|
||
output "job_collection_state" { | ||
value = "${data.azurerm_scheduler_job_collection.jobs.state}" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `name` - (Required) Specifies the name of the Scheduler Job Collection. | ||
|
||
* `resource_group_name` - (Required) Specifies the name of the resource group in which the Scheduler Job Collection resides. | ||
|
||
## Attributes Reference | ||
|
||
The following attributes are exported: | ||
|
||
* `id` - The ID of the Scheduler Job Collection. | ||
|
||
* `location` - The Azure location where the resource exists. | ||
|
||
* `tags` - A mapping of tags assigned to the resource. | ||
|
||
* `sku` - The Job Collection's pricing level's SKU. | ||
|
||
* `state` - The Job Collection's state. | ||
|
||
* `quota` - The Job collection quotas as documented in the `quota` block below. | ||
|
||
The `quota` block supports: | ||
|
||
* `max_job_count` - Sets the maximum number of jobs in the collection. | ||
|
||
* `max_recurrence_frequency` - The maximum frequency of recurrence. | ||
|
||
* `max_retry_interval` - The maximum interval between retries. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we set the other fields here? e.g.
location
,resource_group_name
,name
etc