diff --git a/azurerm/config.go b/azurerm/config.go index 5b02f11c51f0..a87180944416 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -24,7 +24,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/eventgrid/mgmt/2018-01-01/eventgrid" "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" "github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac" - "github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices" + "github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices" keyVault "github.com/Azure/azure-sdk-for-go/services/keyvault/2016-10-01/keyvault" "github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2016-10-01/keyvault" "github.com/Azure/azure-sdk-for-go/services/logic/mgmt/2016-06-01/logic" diff --git a/azurerm/import_arm_iothub_test.go b/azurerm/import_arm_iothub_test.go index 6e33e6a1a7b9..23f8ab35d8f1 100644 --- a/azurerm/import_arm_iothub_test.go +++ b/azurerm/import_arm_iothub_test.go @@ -11,7 +11,30 @@ func TestAccAzureRMIotHub_importBasic(t *testing.T) { resourceName := "azurerm_iothub.test" ri := acctest.RandInt() - config := testAccAzureRMIotHub_basicStandard(ri, testLocation()) + config := testAccAzureRMIotHub_basic(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMIotHubDestroy, + Steps: []resource.TestStep{ + { + Config: config, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMIotHub_importStandard(t *testing.T) { + resourceName := "azurerm_iothub.test" + + ri := acctest.RandInt() + config := testAccAzureRMIotHub_standard(ri, testLocation()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/azurerm/resource_arm_iothub.go b/azurerm/resource_arm_iothub.go index aa3bc77af594..aa8aa71bafb0 100644 --- a/azurerm/resource_arm_iothub.go +++ b/azurerm/resource_arm_iothub.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices" + "github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" @@ -47,6 +47,9 @@ func resourceArmIotHub() *schema.Resource { Required: true, DiffSuppressFunc: ignoreCaseDiffSuppressFunc, ValidateFunc: validation.StringInSlice([]string{ + string(devices.B1), + string(devices.B2), + string(devices.B3), string(devices.F1), string(devices.S1), string(devices.S2), @@ -59,6 +62,7 @@ func resourceArmIotHub() *schema.Resource { Required: true, DiffSuppressFunc: ignoreCaseDiffSuppressFunc, ValidateFunc: validation.StringInSlice([]string{ + string(devices.Basic), string(devices.Free), string(devices.Standard), }, true), @@ -119,7 +123,6 @@ func resourceArmIotHub() *schema.Resource { func resourceArmIotHubCreateAndUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient).iothubResourceClient ctx := meta.(*ArmClient).StopContext - subscriptionID := meta.(*ArmClient).subscriptionId name := d.Get("name").(string) resourceGroup := d.Get("resource_group_name").(string) @@ -143,12 +146,10 @@ func resourceArmIotHubCreateAndUpdate(d *schema.ResourceData, meta interface{}) tags := d.Get("tags").(map[string]interface{}) properties := devices.IotHubDescription{ - Name: utils.String(name), - Location: utils.String(location), - Resourcegroup: utils.String(resourceGroup), - Subscriptionid: utils.String(subscriptionID), - Sku: &skuInfo, - Tags: expandTags(tags), + Name: utils.String(name), + Location: utils.String(location), + Sku: &skuInfo, + Tags: expandTags(tags), } future, err := client.CreateOrUpdate(ctx, resourceGroup, name, properties, "") @@ -282,7 +283,7 @@ func iothubStateStatusCodeRefreshFunc(ctx context.Context, client devices.IotHub func expandIoTHubSku(d *schema.ResourceData) devices.IotHubSkuInfo { skuList := d.Get("sku").([]interface{}) skuMap := skuList[0].(map[string]interface{}) - cap := int64(skuMap["capacity"].(int)) + capacity := int64(skuMap["capacity"].(int)) name := skuMap["name"].(string) tier := skuMap["tier"].(string) @@ -290,7 +291,7 @@ func expandIoTHubSku(d *schema.ResourceData) devices.IotHubSkuInfo { return devices.IotHubSkuInfo{ Name: devices.IotHubSku(name), Tier: devices.IotHubSkuTier(tier), - Capacity: &cap, + Capacity: utils.Int64(capacity), } } diff --git a/azurerm/resource_arm_iothub_test.go b/azurerm/resource_arm_iothub_test.go index 40569d1b893f..91e394cc6d79 100644 --- a/azurerm/resource_arm_iothub_test.go +++ b/azurerm/resource_arm_iothub_test.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform/terraform" ) -func TestAccAzureRMIotHub_basicStandard(t *testing.T) { +func TestAccAzureRMIotHub_basic(t *testing.T) { rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ @@ -19,14 +19,31 @@ func TestAccAzureRMIotHub_basicStandard(t *testing.T) { CheckDestroy: testCheckAzureRMIotHubDestroy, Steps: []resource.TestStep{ { - Config: testAccAzureRMIotHub_basicStandard(rInt, testLocation()), + Config: testAccAzureRMIotHub_basic(rInt, testLocation()), Check: resource.ComposeTestCheckFunc( testCheckAzureRMIotHubExists("azurerm_iothub.test"), ), }, }, }) +} + +func TestAccAzureRMIotHub_standard(t *testing.T) { + rInt := acctest.RandInt() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMIotHubDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMIotHub_standard(rInt, testLocation()), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMIotHubExists("azurerm_iothub.test"), + ), + }, + }, + }) } func testCheckAzureRMIotHubDestroy(s *terraform.State) error { @@ -83,7 +100,31 @@ func testCheckAzureRMIotHubExists(name string) resource.TestCheckFunc { } } -func testAccAzureRMIotHub_basicStandard(rInt int, location string) string { +func testAccAzureRMIotHub_basic(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "foo" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_iothub" "test" { + name = "acctestIoTHub-%d" + resource_group_name = "${azurerm_resource_group.foo.name}" + location = "${azurerm_resource_group.foo.location}" + sku { + name = "B1" + tier = "Basic" + capacity = "1" + } + + tags { + "purpose" = "testing" + } +} +`, rInt, location, rInt) +} + +func testAccAzureRMIotHub_standard(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "foo" { name = "acctestRG-%d" diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/certificates.go b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/certificates.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/certificates.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/certificates.go index 8939377627d6..9b05fe39655b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/certificates.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/certificates.go @@ -85,7 +85,7 @@ func (client CertificatesClient) CreateOrUpdatePreparer(ctx context.Context, res "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -167,7 +167,7 @@ func (client CertificatesClient) DeletePreparer(ctx context.Context, resourceGro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -244,7 +244,7 @@ func (client CertificatesClient) GenerateVerificationCodePreparer(ctx context.Co "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -320,7 +320,7 @@ func (client CertificatesClient) GetPreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -387,7 +387,7 @@ func (client CertificatesClient) ListByIotHubPreparer(ctx context.Context, resou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -465,7 +465,7 @@ func (client CertificatesClient) VerifyPreparer(ctx context.Context, resourceGro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/client.go similarity index 98% rename from vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/client.go index e57aac2e56b1..cbe7e7e40a2f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/client.go @@ -1,4 +1,4 @@ -// Package devices implements the Azure ARM Devices service API version 2017-07-01. +// Package devices implements the Azure ARM Devices service API version 2018-04-01. // // Use this API to manage the IoT hubs in your Azure subscription. package devices diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/iothubresource.go b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/iothubresource.go similarity index 81% rename from vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/iothubresource.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/iothubresource.go index 45879941de4e..3c5a515b96b9 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/iothubresource.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/iothubresource.go @@ -78,7 +78,7 @@ func (client IotHubResourceClient) CheckNameAvailabilityPreparer(ctx context.Con "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -151,7 +151,7 @@ func (client IotHubResourceClient) CreateEventHubConsumerGroupPreparer(ctx conte "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -196,34 +196,31 @@ func (client IotHubResourceClient) CreateEventHubConsumerGroupResponder(resp *ht func (client IotHubResourceClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, iotHubDescription IotHubDescription, ifMatch string) (result IotHubResourceCreateOrUpdateFuture, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: iotHubDescription, - Constraints: []validation.Constraint{{Target: "iotHubDescription.Subscriptionid", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "iotHubDescription.Resourcegroup", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "iotHubDescription.Properties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.Routing", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.Routing.FallbackRoute", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.Routing.FallbackRoute.Source", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "iotHubDescription.Properties.Routing.FallbackRoute.EndpointNames", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.Routing.FallbackRoute.EndpointNames", Name: validation.MaxItems, Rule: 1, Chain: nil}, - {Target: "iotHubDescription.Properties.Routing.FallbackRoute.EndpointNames", Name: validation.MinItems, Rule: 1, Chain: nil}, - }}, - {Target: "iotHubDescription.Properties.Routing.FallbackRoute.IsEnabled", Name: validation.Null, Rule: true, Chain: nil}, - }}, - }}, - {Target: "iotHubDescription.Properties.CloudToDevice", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.CloudToDevice.MaxDeliveryCount", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.CloudToDevice.MaxDeliveryCount", Name: validation.InclusiveMaximum, Rule: int64(100), Chain: nil}, - {Target: "iotHubDescription.Properties.CloudToDevice.MaxDeliveryCount", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + Constraints: []validation.Constraint{{Target: "iotHubDescription.Properties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.Routing", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.Routing.FallbackRoute", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.Routing.FallbackRoute.Source", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotHubDescription.Properties.Routing.FallbackRoute.EndpointNames", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.Routing.FallbackRoute.EndpointNames", Name: validation.MaxItems, Rule: 1, Chain: nil}, + {Target: "iotHubDescription.Properties.Routing.FallbackRoute.EndpointNames", Name: validation.MinItems, Rule: 1, Chain: nil}, }}, - {Target: "iotHubDescription.Properties.CloudToDevice.Feedback", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.CloudToDevice.Feedback.MaxDeliveryCount", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.CloudToDevice.Feedback.MaxDeliveryCount", Name: validation.InclusiveMaximum, Rule: int64(100), Chain: nil}, - {Target: "iotHubDescription.Properties.CloudToDevice.Feedback.MaxDeliveryCount", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, - }}, - }}, - }}, + {Target: "iotHubDescription.Properties.Routing.FallbackRoute.IsEnabled", Name: validation.Null, Rule: true, Chain: nil}, + }}, }}, - {Target: "iotHubDescription.Sku", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "iotHubDescription.Sku.Capacity", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + {Target: "iotHubDescription.Properties.CloudToDevice", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.CloudToDevice.MaxDeliveryCount", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.CloudToDevice.MaxDeliveryCount", Name: validation.InclusiveMaximum, Rule: int64(100), Chain: nil}, + {Target: "iotHubDescription.Properties.CloudToDevice.MaxDeliveryCount", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}, + {Target: "iotHubDescription.Properties.CloudToDevice.Feedback", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.CloudToDevice.Feedback.MaxDeliveryCount", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "iotHubDescription.Properties.CloudToDevice.Feedback.MaxDeliveryCount", Name: validation.InclusiveMaximum, Rule: int64(100), Chain: nil}, + {Target: "iotHubDescription.Properties.CloudToDevice.Feedback.MaxDeliveryCount", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}, + }}, + }}, + }}, + {Target: "iotHubDescription.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { return result, validation.NewError("devices.IotHubResourceClient", "CreateOrUpdate", err.Error()) } @@ -250,7 +247,7 @@ func (client IotHubResourceClient) CreateOrUpdatePreparer(ctx context.Context, r "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -327,7 +324,7 @@ func (client IotHubResourceClient) DeletePreparer(ctx context.Context, resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -408,7 +405,7 @@ func (client IotHubResourceClient) DeleteEventHubConsumerGroupPreparer(ctx conte "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -484,7 +481,7 @@ func (client IotHubResourceClient) ExportDevicesPreparer(ctx context.Context, re "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -553,7 +550,7 @@ func (client IotHubResourceClient) GetPreparer(ctx context.Context, resourceGrou "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -586,6 +583,98 @@ func (client IotHubResourceClient) GetResponder(resp *http.Response) (result Iot return } +// GetEndpointHealth get the health for routing endpoints. +func (client IotHubResourceClient) GetEndpointHealth(ctx context.Context, resourceGroupName string, iotHubName string) (result EndpointHealthDataListResultPage, err error) { + result.fn = client.getEndpointHealthNextResults + req, err := client.GetEndpointHealthPreparer(ctx, resourceGroupName, iotHubName) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "GetEndpointHealth", nil, "Failure preparing request") + return + } + + resp, err := client.GetEndpointHealthSender(req) + if err != nil { + result.ehdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "GetEndpointHealth", resp, "Failure sending request") + return + } + + result.ehdlr, err = client.GetEndpointHealthResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "GetEndpointHealth", resp, "Failure responding to request") + } + + return +} + +// GetEndpointHealthPreparer prepares the GetEndpointHealth request. +func (client IotHubResourceClient) GetEndpointHealthPreparer(ctx context.Context, resourceGroupName string, iotHubName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotHubName": autorest.Encode("path", iotHubName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetEndpointHealthSender sends the GetEndpointHealth request. The method will close the +// http.Response Body if it receives an error. +func (client IotHubResourceClient) GetEndpointHealthSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetEndpointHealthResponder handles the response to the GetEndpointHealth request. The method always +// closes the http.Response Body. +func (client IotHubResourceClient) GetEndpointHealthResponder(resp *http.Response) (result EndpointHealthDataListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// getEndpointHealthNextResults retrieves the next set of results, if any. +func (client IotHubResourceClient) getEndpointHealthNextResults(lastResults EndpointHealthDataListResult) (result EndpointHealthDataListResult, err error) { + req, err := lastResults.endpointHealthDataListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "getEndpointHealthNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.GetEndpointHealthSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "getEndpointHealthNextResults", resp, "Failure sending next results request") + } + result, err = client.GetEndpointHealthResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "getEndpointHealthNextResults", resp, "Failure responding to next results request") + } + return +} + +// GetEndpointHealthComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotHubResourceClient) GetEndpointHealthComplete(ctx context.Context, resourceGroupName string, iotHubName string) (result EndpointHealthDataListResultIterator, err error) { + result.page, err = client.GetEndpointHealth(ctx, resourceGroupName, iotHubName) + return +} + // GetEventHubConsumerGroup get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. // Parameters: // resourceGroupName - the name of the resource group that contains the IoT hub. @@ -624,7 +713,7 @@ func (client IotHubResourceClient) GetEventHubConsumerGroupPreparer(ctx context. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -694,7 +783,7 @@ func (client IotHubResourceClient) GetJobPreparer(ctx context.Context, resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -764,7 +853,7 @@ func (client IotHubResourceClient) GetKeysForKeyNamePreparer(ctx context.Context "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -832,7 +921,7 @@ func (client IotHubResourceClient) GetQuotaMetricsPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -926,7 +1015,7 @@ func (client IotHubResourceClient) GetStatsPreparer(ctx context.Context, resourc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -994,7 +1083,7 @@ func (client IotHubResourceClient) GetValidSkusPreparer(ctx context.Context, res "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1098,7 +1187,7 @@ func (client IotHubResourceClient) ImportDevicesPreparer(ctx context.Context, re "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1166,7 +1255,7 @@ func (client IotHubResourceClient) ListByResourceGroupPreparer(ctx context.Conte "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1256,7 +1345,7 @@ func (client IotHubResourceClient) ListBySubscriptionPreparer(ctx context.Contex "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1354,7 +1443,7 @@ func (client IotHubResourceClient) ListEventHubConsumerGroupsPreparer(ctx contex "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1450,7 +1539,7 @@ func (client IotHubResourceClient) ListJobsPreparer(ctx context.Context, resourc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1546,7 +1635,7 @@ func (client IotHubResourceClient) ListKeysPreparer(ctx context.Context, resourc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1605,3 +1694,231 @@ func (client IotHubResourceClient) ListKeysComplete(ctx context.Context, resourc result.page, err = client.ListKeys(ctx, resourceGroupName, resourceName) return } + +// TestAllRoutes test all routes configured in this Iot Hub +// Parameters: +// input - input for testing all routes +// iotHubName - iotHub to be tested +// resourceGroupName - resource group which Iot Hub belongs to +func (client IotHubResourceClient) TestAllRoutes(ctx context.Context, input TestAllRoutesInput, iotHubName string, resourceGroupName string) (result TestAllRoutesResult, err error) { + req, err := client.TestAllRoutesPreparer(ctx, input, iotHubName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "TestAllRoutes", nil, "Failure preparing request") + return + } + + resp, err := client.TestAllRoutesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "TestAllRoutes", resp, "Failure sending request") + return + } + + result, err = client.TestAllRoutesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "TestAllRoutes", resp, "Failure responding to request") + } + + return +} + +// TestAllRoutesPreparer prepares the TestAllRoutes request. +func (client IotHubResourceClient) TestAllRoutesPreparer(ctx context.Context, input TestAllRoutesInput, iotHubName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotHubName": autorest.Encode("path", iotHubName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TestAllRoutesSender sends the TestAllRoutes request. The method will close the +// http.Response Body if it receives an error. +func (client IotHubResourceClient) TestAllRoutesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// TestAllRoutesResponder handles the response to the TestAllRoutes request. The method always +// closes the http.Response Body. +func (client IotHubResourceClient) TestAllRoutesResponder(resp *http.Response) (result TestAllRoutesResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// TestRoute test the new route for this Iot Hub +// Parameters: +// input - route that needs to be tested +// iotHubName - iotHub to be tested +// resourceGroupName - resource group which Iot Hub belongs to +func (client IotHubResourceClient) TestRoute(ctx context.Context, input TestRouteInput, iotHubName string, resourceGroupName string) (result TestRouteResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: input, + Constraints: []validation.Constraint{{Target: "input.Route", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "input.Route.Name", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "input.Route.Name", Name: validation.Pattern, Rule: `^[A-Za-z0-9-._]{1,64}$`, Chain: nil}}}, + {Target: "input.Route.EndpointNames", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "input.Route.EndpointNames", Name: validation.MaxItems, Rule: 1, Chain: nil}, + {Target: "input.Route.EndpointNames", Name: validation.MinItems, Rule: 1, Chain: nil}, + }}, + {Target: "input.Route.IsEnabled", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("devices.IotHubResourceClient", "TestRoute", err.Error()) + } + + req, err := client.TestRoutePreparer(ctx, input, iotHubName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "TestRoute", nil, "Failure preparing request") + return + } + + resp, err := client.TestRouteSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "TestRoute", resp, "Failure sending request") + return + } + + result, err = client.TestRouteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "TestRoute", resp, "Failure responding to request") + } + + return +} + +// TestRoutePreparer prepares the TestRoute request. +func (client IotHubResourceClient) TestRoutePreparer(ctx context.Context, input TestRouteInput, iotHubName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotHubName": autorest.Encode("path", iotHubName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// TestRouteSender sends the TestRoute request. The method will close the +// http.Response Body if it receives an error. +func (client IotHubResourceClient) TestRouteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// TestRouteResponder handles the response to the TestRoute request. The method always +// closes the http.Response Body. +func (client IotHubResourceClient) TestRouteResponder(resp *http.Response) (result TestRouteResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method +// Parameters: +// resourceGroupName - resource group identifier. +// resourceName - name of iot hub to update. +// iotHubTags - updated tag information to set into the iot hub instance. +func (client IotHubResourceClient) Update(ctx context.Context, resourceGroupName string, resourceName string, iotHubTags TagsResource) (result IotHubResourceUpdateFuture, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, iotHubTags) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client IotHubResourceClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, iotHubTags TagsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", pathParameters), + autorest.WithJSON(iotHubTags), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client IotHubResourceClient) UpdateSender(req *http.Request) (future IotHubResourceUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client IotHubResourceClient) UpdateResponder(resp *http.Response) (result IotHubDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/models.go similarity index 80% rename from vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/models.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/models.go index 08a8d037aa8b..957f00ba0ec2 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/models.go @@ -82,6 +82,25 @@ func PossibleCapabilitiesValues() []Capabilities { return []Capabilities{DeviceManagement, None} } +// EndpointHealthStatus enumerates the values for endpoint health status. +type EndpointHealthStatus string + +const ( + // Dead ... + Dead EndpointHealthStatus = "dead" + // Healthy ... + Healthy EndpointHealthStatus = "healthy" + // Unhealthy ... + Unhealthy EndpointHealthStatus = "unhealthy" + // Unknown ... + Unknown EndpointHealthStatus = "unknown" +) + +// PossibleEndpointHealthStatusValues returns an array of possible values for the EndpointHealthStatus const type. +func PossibleEndpointHealthStatusValues() []EndpointHealthStatus { + return []EndpointHealthStatus{Dead, Healthy, Unhealthy, Unknown} +} + // IotHubNameUnavailabilityReason enumerates the values for iot hub name unavailability reason. type IotHubNameUnavailabilityReason string @@ -118,6 +137,12 @@ func PossibleIotHubScaleTypeValues() []IotHubScaleType { type IotHubSku string const ( + // B1 ... + B1 IotHubSku = "B1" + // B2 ... + B2 IotHubSku = "B2" + // B3 ... + B3 IotHubSku = "B3" // F1 ... F1 IotHubSku = "F1" // S1 ... @@ -130,13 +155,15 @@ const ( // PossibleIotHubSkuValues returns an array of possible values for the IotHubSku const type. func PossibleIotHubSkuValues() []IotHubSku { - return []IotHubSku{F1, S1, S2, S3} + return []IotHubSku{B1, B2, B3, F1, S1, S2, S3} } // IotHubSkuTier enumerates the values for iot hub sku tier. type IotHubSkuTier string const ( + // Basic ... + Basic IotHubSkuTier = "Basic" // Free ... Free IotHubSkuTier = "Free" // Standard ... @@ -145,7 +172,7 @@ const ( // PossibleIotHubSkuTierValues returns an array of possible values for the IotHubSkuTier const type. func PossibleIotHubSkuTierValues() []IotHubSkuTier { - return []IotHubSkuTier{Free, Standard} + return []IotHubSkuTier{Basic, Free, Standard} } // IPFilterActionType enumerates the values for ip filter action type. @@ -167,23 +194,23 @@ func PossibleIPFilterActionTypeValues() []IPFilterActionType { type JobStatus string const ( - // Cancelled ... - Cancelled JobStatus = "cancelled" - // Completed ... - Completed JobStatus = "completed" - // Enqueued ... - Enqueued JobStatus = "enqueued" - // Failed ... - Failed JobStatus = "failed" - // Running ... - Running JobStatus = "running" - // Unknown ... - Unknown JobStatus = "unknown" + // JobStatusCancelled ... + JobStatusCancelled JobStatus = "cancelled" + // JobStatusCompleted ... + JobStatusCompleted JobStatus = "completed" + // JobStatusEnqueued ... + JobStatusEnqueued JobStatus = "enqueued" + // JobStatusFailed ... + JobStatusFailed JobStatus = "failed" + // JobStatusRunning ... + JobStatusRunning JobStatus = "running" + // JobStatusUnknown ... + JobStatusUnknown JobStatus = "unknown" ) // PossibleJobStatusValues returns an array of possible values for the JobStatus const type. func PossibleJobStatusValues() []JobStatus { - return []JobStatus{Cancelled, Completed, Enqueued, Failed, Running, Unknown} + return []JobStatus{JobStatusCancelled, JobStatusCompleted, JobStatusEnqueued, JobStatusFailed, JobStatusRunning, JobStatusUnknown} } // JobType enumerates the values for job type. @@ -236,23 +263,57 @@ func PossibleOperationMonitoringLevelValues() []OperationMonitoringLevel { return []OperationMonitoringLevel{OperationMonitoringLevelError, OperationMonitoringLevelErrorInformation, OperationMonitoringLevelInformation, OperationMonitoringLevelNone} } +// RouteErrorSeverity enumerates the values for route error severity. +type RouteErrorSeverity string + +const ( + // Error ... + Error RouteErrorSeverity = "error" + // Warning ... + Warning RouteErrorSeverity = "warning" +) + +// PossibleRouteErrorSeverityValues returns an array of possible values for the RouteErrorSeverity const type. +func PossibleRouteErrorSeverityValues() []RouteErrorSeverity { + return []RouteErrorSeverity{Error, Warning} +} + // RoutingSource enumerates the values for routing source. type RoutingSource string const ( - // DeviceJobLifecycleEvents ... - DeviceJobLifecycleEvents RoutingSource = "DeviceJobLifecycleEvents" - // DeviceLifecycleEvents ... - DeviceLifecycleEvents RoutingSource = "DeviceLifecycleEvents" - // DeviceMessages ... - DeviceMessages RoutingSource = "DeviceMessages" - // TwinChangeEvents ... - TwinChangeEvents RoutingSource = "TwinChangeEvents" + // RoutingSourceDeviceJobLifecycleEvents ... + RoutingSourceDeviceJobLifecycleEvents RoutingSource = "DeviceJobLifecycleEvents" + // RoutingSourceDeviceLifecycleEvents ... + RoutingSourceDeviceLifecycleEvents RoutingSource = "DeviceLifecycleEvents" + // RoutingSourceDeviceMessages ... + RoutingSourceDeviceMessages RoutingSource = "DeviceMessages" + // RoutingSourceInvalid ... + RoutingSourceInvalid RoutingSource = "Invalid" + // RoutingSourceTwinChangeEvents ... + RoutingSourceTwinChangeEvents RoutingSource = "TwinChangeEvents" ) // PossibleRoutingSourceValues returns an array of possible values for the RoutingSource const type. func PossibleRoutingSourceValues() []RoutingSource { - return []RoutingSource{DeviceJobLifecycleEvents, DeviceLifecycleEvents, DeviceMessages, TwinChangeEvents} + return []RoutingSource{RoutingSourceDeviceJobLifecycleEvents, RoutingSourceDeviceLifecycleEvents, RoutingSourceDeviceMessages, RoutingSourceInvalid, RoutingSourceTwinChangeEvents} +} + +// TestResultStatus enumerates the values for test result status. +type TestResultStatus string + +const ( + // False ... + False TestResultStatus = "false" + // True ... + True TestResultStatus = "true" + // Undefined ... + Undefined TestResultStatus = "undefined" +) + +// PossibleTestResultStatusValues returns an array of possible values for the TestResultStatus const type. +func PossibleTestResultStatusValues() []TestResultStatus { + return []TestResultStatus{False, True, Undefined} } // CertificateBodyDescription the JSON-serialized X509 Certificate. @@ -296,6 +357,8 @@ type CertificateProperties struct { Created *date.TimeRFC1123 `json:"created,omitempty"` // Updated - The certificate's last update date and time. Updated *date.TimeRFC1123 `json:"updated,omitempty"` + // Certificate - The certificate content + Certificate *string `json:"certificate,omitempty"` } // CertificatePropertiesWithNonce the description of an X509 CA Certificate including the challenge nonce issued @@ -315,6 +378,8 @@ type CertificatePropertiesWithNonce struct { Updated *date.TimeRFC1123 `json:"updated,omitempty"` // VerificationCode - The certificate's verification code that will be used for proof of possession. VerificationCode *string `json:"verificationCode,omitempty"` + // Certificate - The certificate content + Certificate *string `json:"certificate,omitempty"` } // CertificateVerificationDescription the JSON-serialized leaf certificate @@ -346,34 +411,148 @@ type CloudToDeviceProperties struct { Feedback *FeedbackProperties `json:"feedback,omitempty"` } +// EndpointHealthData the health data for an endpoint +type EndpointHealthData struct { + // EndpointID - Id of the endpoint + EndpointID *string `json:"endpointId,omitempty"` + // HealthStatus - Health status. Possible values include: 'Unknown', 'Healthy', 'Unhealthy', 'Dead' + HealthStatus EndpointHealthStatus `json:"healthStatus,omitempty"` +} + +// EndpointHealthDataListResult the JSON-serialized array of EndpointHealthData objects with a next link. +type EndpointHealthDataListResult struct { + autorest.Response `json:"-"` + // Value - JSON-serialized array of Endpoint health data + Value *[]EndpointHealthData `json:"value,omitempty"` + // NextLink - Link to more results + NextLink *string `json:"nextLink,omitempty"` +} + +// EndpointHealthDataListResultIterator provides access to a complete listing of EndpointHealthData values. +type EndpointHealthDataListResultIterator struct { + i int + page EndpointHealthDataListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EndpointHealthDataListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EndpointHealthDataListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter EndpointHealthDataListResultIterator) Response() EndpointHealthDataListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter EndpointHealthDataListResultIterator) Value() EndpointHealthData { + if !iter.page.NotDone() { + return EndpointHealthData{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (ehdlr EndpointHealthDataListResult) IsEmpty() bool { + return ehdlr.Value == nil || len(*ehdlr.Value) == 0 +} + +// endpointHealthDataListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ehdlr EndpointHealthDataListResult) endpointHealthDataListResultPreparer() (*http.Request, error) { + if ehdlr.NextLink == nil || len(to.String(ehdlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ehdlr.NextLink))) +} + +// EndpointHealthDataListResultPage contains a page of EndpointHealthData values. +type EndpointHealthDataListResultPage struct { + fn func(EndpointHealthDataListResult) (EndpointHealthDataListResult, error) + ehdlr EndpointHealthDataListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EndpointHealthDataListResultPage) Next() error { + next, err := page.fn(page.ehdlr) + if err != nil { + return err + } + page.ehdlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EndpointHealthDataListResultPage) NotDone() bool { + return !page.ehdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EndpointHealthDataListResultPage) Response() EndpointHealthDataListResult { + return page.ehdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EndpointHealthDataListResultPage) Values() []EndpointHealthData { + if page.ehdlr.IsEmpty() { + return nil + } + return *page.ehdlr.Value +} + // ErrorDetails error details. type ErrorDetails struct { // Code - The error code. - Code *string `json:"Code,omitempty"` + Code *string `json:"code,omitempty"` // HTTPStatusCode - The HTTP status code. - HTTPStatusCode *string `json:"HttpStatusCode,omitempty"` + HTTPStatusCode *string `json:"httpStatusCode,omitempty"` // Message - The error message. - Message *string `json:"Message,omitempty"` + Message *string `json:"message,omitempty"` // Details - The error details. - Details *string `json:"Details,omitempty"` + Details *string `json:"details,omitempty"` } // EventHubConsumerGroupInfo the properties of the EventHubConsumerGroupInfo object. type EventHubConsumerGroupInfo struct { autorest.Response `json:"-"` - // Tags - The tags. - Tags map[string]*string `json:"tags"` + // Properties - The tags. + Properties map[string]*string `json:"properties"` // ID - The Event Hub-compatible consumer group identifier. ID *string `json:"id,omitempty"` // Name - The Event Hub-compatible consumer group name. Name *string `json:"name,omitempty"` + // Type - the resource type. + Type *string `json:"type,omitempty"` + // Etag - The etag. + Etag *string `json:"etag,omitempty"` } // MarshalJSON is the custom marshaler for EventHubConsumerGroupInfo. func (ehcgi EventHubConsumerGroupInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ehcgi.Tags != nil { - objectMap["tags"] = ehcgi.Tags + if ehcgi.Properties != nil { + objectMap["properties"] = ehcgi.Properties } if ehcgi.ID != nil { objectMap["id"] = ehcgi.ID @@ -381,6 +560,12 @@ func (ehcgi EventHubConsumerGroupInfo) MarshalJSON() ([]byte, error) { if ehcgi.Name != nil { objectMap["name"] = ehcgi.Name } + if ehcgi.Type != nil { + objectMap["type"] = ehcgi.Type + } + if ehcgi.Etag != nil { + objectMap["etag"] = ehcgi.Etag + } return json.Marshal(objectMap) } @@ -388,13 +573,14 @@ func (ehcgi EventHubConsumerGroupInfo) MarshalJSON() ([]byte, error) { // next link. type EventHubConsumerGroupsListResult struct { autorest.Response `json:"-"` - // Value - The array of Event Hub-compatible consumer group names. - Value *[]string `json:"value,omitempty"` + // Value - List of consumer groups objects + Value *[]EventHubConsumerGroupInfo `json:"value,omitempty"` // NextLink - The next link. NextLink *string `json:"nextLink,omitempty"` } -// EventHubConsumerGroupsListResultIterator provides access to a complete listing of string values. +// EventHubConsumerGroupsListResultIterator provides access to a complete listing of EventHubConsumerGroupInfo +// values. type EventHubConsumerGroupsListResultIterator struct { i int page EventHubConsumerGroupsListResultPage @@ -428,9 +614,9 @@ func (iter EventHubConsumerGroupsListResultIterator) Response() EventHubConsumer // Value returns the current value or a zero-initialized value if the // iterator has advanced beyond the end of the collection. -func (iter EventHubConsumerGroupsListResultIterator) Value() string { +func (iter EventHubConsumerGroupsListResultIterator) Value() EventHubConsumerGroupInfo { if !iter.page.NotDone() { - return "" + return EventHubConsumerGroupInfo{} } return iter.page.Values()[iter.i] } @@ -452,7 +638,7 @@ func (ehcglr EventHubConsumerGroupsListResult) eventHubConsumerGroupsListResultP autorest.WithBaseURL(to.String(ehcglr.NextLink))) } -// EventHubConsumerGroupsListResultPage contains a page of string values. +// EventHubConsumerGroupsListResultPage contains a page of EventHubConsumerGroupInfo values. type EventHubConsumerGroupsListResultPage struct { fn func(EventHubConsumerGroupsListResult) (EventHubConsumerGroupsListResult, error) ehcglr EventHubConsumerGroupsListResult @@ -480,7 +666,7 @@ func (page EventHubConsumerGroupsListResultPage) Response() EventHubConsumerGrou } // Values returns the slice of values for the current page or nil if there are no values. -func (page EventHubConsumerGroupsListResultPage) Values() []string { +func (page EventHubConsumerGroupsListResultPage) Values() []EventHubConsumerGroupInfo { if page.ehcglr.IsEmpty() { return nil } @@ -504,14 +690,16 @@ type EventHubProperties struct { // ExportDevicesRequest use to provide parameters when requesting an export of all devices in the IoT hub. type ExportDevicesRequest struct { // ExportBlobContainerURI - The export blob container URI. - ExportBlobContainerURI *string `json:"ExportBlobContainerUri,omitempty"` + ExportBlobContainerURI *string `json:"exportBlobContainerUri,omitempty"` // ExcludeKeys - The value indicating whether keys should be excluded during export. - ExcludeKeys *bool `json:"ExcludeKeys,omitempty"` + ExcludeKeys *bool `json:"excludeKeys,omitempty"` } // FallbackRouteProperties the properties of the fallback route. IoT Hub uses these properties when it routes // messages to the fallback endpoint. type FallbackRouteProperties struct { + // Name - The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Name *string `json:"name,omitempty"` // Source - The source to which the routing rule is to be applied to. For example, DeviceMessages Source *string `json:"source,omitempty"` // Condition - The condition which is evaluated in order to apply the fallback route. If the condition is not provided it will evaluate to true by default. For grammar, See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language @@ -535,9 +723,9 @@ type FeedbackProperties struct { // ImportDevicesRequest use to provide parameters when requesting an import of all devices in the hub. type ImportDevicesRequest struct { // InputBlobContainerURI - The input blob container URI. - InputBlobContainerURI *string `json:"InputBlobContainerUri,omitempty"` + InputBlobContainerURI *string `json:"inputBlobContainerUri,omitempty"` // OutputBlobContainerURI - The output blob container URI. - OutputBlobContainerURI *string `json:"OutputBlobContainerUri,omitempty"` + OutputBlobContainerURI *string `json:"outputBlobContainerUri,omitempty"` } // IotHubCapacity ioT Hub capacity information. @@ -555,14 +743,12 @@ type IotHubCapacity struct { // IotHubDescription the description of the IoT hub. type IotHubDescription struct { autorest.Response `json:"-"` - // Subscriptionid - The subscription identifier. - Subscriptionid *string `json:"subscriptionid,omitempty"` - // Resourcegroup - The name of the resource group that contains the IoT hub. A resource group name uniquely identifies the resource group within the subscription. - Resourcegroup *string `json:"resourcegroup,omitempty"` // Etag - The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. - Etag *string `json:"etag,omitempty"` + Etag *string `json:"etag,omitempty"` + // Properties - IotHub properties Properties *IotHubProperties `json:"properties,omitempty"` - Sku *IotHubSkuInfo `json:"sku,omitempty"` + // Sku - IotHub SKU info + Sku *IotHubSkuInfo `json:"sku,omitempty"` // ID - The resource identifier. ID *string `json:"id,omitempty"` // Name - The resource name. @@ -578,12 +764,6 @@ type IotHubDescription struct { // MarshalJSON is the custom marshaler for IotHubDescription. func (ihd IotHubDescription) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if ihd.Subscriptionid != nil { - objectMap["subscriptionid"] = ihd.Subscriptionid - } - if ihd.Resourcegroup != nil { - objectMap["resourcegroup"] = ihd.Resourcegroup - } if ihd.Etag != nil { objectMap["etag"] = ihd.Etag } @@ -732,6 +912,8 @@ type IotHubProperties struct { IPFilterRules *[]IPFilterRule `json:"ipFilterRules,omitempty"` // ProvisioningState - The provisioning state. ProvisioningState *string `json:"provisioningState,omitempty"` + // State - Thehub state state. + State *string `json:"state,omitempty"` // HostName - The name of the host. HostName *string `json:"hostName,omitempty"` // EventHubEndpoints - The Event Hub-compatible endpoint properties. The possible keys to this dictionary are events and operationsMonitoringEvents. Both of these keys have to be present in the dictionary while making create or update calls for the IoT hub. @@ -763,6 +945,9 @@ func (ihp IotHubProperties) MarshalJSON() ([]byte, error) { if ihp.ProvisioningState != nil { objectMap["provisioningState"] = ihp.ProvisioningState } + if ihp.State != nil { + objectMap["state"] = ihp.State + } if ihp.HostName != nil { objectMap["hostName"] = ihp.HostName } @@ -799,11 +984,11 @@ func (ihp IotHubProperties) MarshalJSON() ([]byte, error) { // IotHubQuotaMetricInfo quota metrics properties. type IotHubQuotaMetricInfo struct { // Name - The name of the quota metric. - Name *string `json:"Name,omitempty"` + Name *string `json:"name,omitempty"` // CurrentValue - The current value for the quota metric. - CurrentValue *int64 `json:"CurrentValue,omitempty"` + CurrentValue *int64 `json:"currentValue,omitempty"` // MaxValue - The maximum value of the quota metric. - MaxValue *int64 `json:"MaxValue,omitempty"` + MaxValue *int64 `json:"maxValue,omitempty"` } // IotHubQuotaMetricInfoListResult the JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. @@ -965,12 +1150,42 @@ func (future *IotHubResourceDeleteFuture) Result(client IotHubResourceClient) (s return } +// IotHubResourceUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type IotHubResourceUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *IotHubResourceUpdateFuture) Result(client IotHubResourceClient) (ihd IotHubDescription, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("devices.IotHubResourceUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ihd.Response.Response, err = future.GetResult(sender); err == nil && ihd.Response.Response.StatusCode != http.StatusNoContent { + ihd, err = client.UpdateResponder(ihd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.IotHubResourceUpdateFuture", "Result", ihd.Response.Response, "Failure responding to request") + } + } + return +} + // IotHubSkuDescription SKU properties. type IotHubSkuDescription struct { // ResourceType - The type of the resource. - ResourceType *string `json:"resourceType,omitempty"` - Sku *IotHubSkuInfo `json:"sku,omitempty"` - Capacity *IotHubCapacity `json:"capacity,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + // Sku - The type of the resource. + Sku *IotHubSkuInfo `json:"sku,omitempty"` + // Capacity - IotHub capacity + Capacity *IotHubCapacity `json:"capacity,omitempty"` } // IotHubSkuDescriptionListResult the JSON-serialized array of IotHubSkuDescription objects with a next link. @@ -1077,9 +1292,9 @@ func (page IotHubSkuDescriptionListResultPage) Values() []IotHubSkuDescription { // IotHubSkuInfo information about the SKU of the IoT hub. type IotHubSkuInfo struct { - // Name - The name of the SKU. Possible values include: 'F1', 'S1', 'S2', 'S3' + // Name - The name of the SKU. Possible values include: 'F1', 'S1', 'S2', 'S3', 'B1', 'B2', 'B3' Name IotHubSku `json:"name,omitempty"` - // Tier - The billing tier for the IoT hub. Possible values include: 'Free', 'Standard' + // Tier - The billing tier for the IoT hub. Possible values include: 'Free', 'Standard', 'Basic' Tier IotHubSkuTier `json:"tier,omitempty"` // Capacity - The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. Capacity *int64 `json:"capacity,omitempty"` @@ -1106,7 +1321,7 @@ type JobResponse struct { EndTimeUtc *date.TimeRFC1123 `json:"endTimeUtc,omitempty"` // Type - The type of the job. Possible values include: 'JobTypeUnknown', 'JobTypeExport', 'JobTypeImport', 'JobTypeBackup', 'JobTypeReadDeviceProperties', 'JobTypeWriteDeviceProperties', 'JobTypeUpdateDeviceConfiguration', 'JobTypeRebootDevice', 'JobTypeFactoryResetDevice', 'JobTypeFirmwareUpdate' Type JobType `json:"type,omitempty"` - // Status - The status of the job. Possible values include: 'Unknown', 'Enqueued', 'Running', 'Completed', 'Failed', 'Cancelled' + // Status - The status of the job. Possible values include: 'JobStatusUnknown', 'JobStatusEnqueued', 'JobStatusRunning', 'JobStatusCompleted', 'JobStatusFailed', 'JobStatusCancelled' Status JobStatus `json:"status,omitempty"` // FailureReason - If status == failed, this string containing the reason for the failure. FailureReason *string `json:"failureReason,omitempty"` @@ -1218,6 +1433,12 @@ func (page JobResponseListResultPage) Values() []JobResponse { return *page.jrlr.Value } +// MatchedRoute routes that matched +type MatchedRoute struct { + // Properties - Properties of routes that matched + Properties *RouteProperties `json:"properties,omitempty"` +} + // MessagingEndpointProperties the properties of the messaging endpoints used by this IoT hub. type MessagingEndpointProperties struct { // LockDurationAsIso8601 - The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. @@ -1228,6 +1449,14 @@ type MessagingEndpointProperties struct { MaxDeliveryCount *int32 `json:"maxDeliveryCount,omitempty"` } +// Name name of Iot Hub type +type Name struct { + // Value - IotHub type + Value *string `json:"value,omitempty"` + // LocalizedValue - Localized value of name + LocalizedValue *string `json:"localizedValue,omitempty"` +} + // Operation ioT Hub REST API operation type Operation struct { // Name - Operation name: {provider}/{resource}/{read | write | action | delete} @@ -1249,7 +1478,7 @@ type OperationDisplay struct { // OperationInputs input values. type OperationInputs struct { // Name - The name of the IoT hub to check. - Name *string `json:"Name,omitempty"` + Name *string `json:"name,omitempty"` } // OperationListResult result of the request to list IoT Hub operations. It contains a list of operations and a URL @@ -1417,11 +1646,37 @@ func (r Resource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// RouteCompilationError compilation error when evaluating route +type RouteCompilationError struct { + // Message - Route error message + Message *string `json:"message,omitempty"` + // Severity - Severity of the route error. Possible values include: 'Error', 'Warning' + Severity RouteErrorSeverity `json:"severity,omitempty"` + // Location - Location where the route error happened + Location *RouteErrorRange `json:"location,omitempty"` +} + +// RouteErrorPosition position where the route error happened +type RouteErrorPosition struct { + // Line - Line where the route error happened + Line *int32 `json:"line,omitempty"` + // Column - Column where the route error happened + Column *int32 `json:"column,omitempty"` +} + +// RouteErrorRange range of route errors +type RouteErrorRange struct { + // Start - Start where the route error happened + Start *RouteErrorPosition `json:"start,omitempty"` + // End - End where the route error happened + End *RouteErrorPosition `json:"end,omitempty"` +} + // RouteProperties the properties of a routing rule that your IoT hub uses to route messages to endpoints. type RouteProperties struct { // Name - The name of the route. The name can only include alphanumeric characters, periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. Name *string `json:"name,omitempty"` - // Source - The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: 'DeviceMessages', 'TwinChangeEvents', 'DeviceLifecycleEvents', 'DeviceJobLifecycleEvents' + // Source - The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: 'RoutingSourceInvalid', 'RoutingSourceDeviceMessages', 'RoutingSourceTwinChangeEvents', 'RoutingSourceDeviceLifecycleEvents', 'RoutingSourceDeviceJobLifecycleEvents' Source RoutingSource `json:"source,omitempty"` // Condition - The condition that is evaluated to apply the routing rule. If no condition is provided, it evaluates to true by default. For grammar, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language Condition *string `json:"condition,omitempty"` @@ -1457,6 +1712,31 @@ type RoutingEventHubProperties struct { ResourceGroup *string `json:"resourceGroup,omitempty"` } +// RoutingMessage routing message +type RoutingMessage struct { + // Body - Body of routing message + Body *string `json:"body,omitempty"` + // AppProperties - App properties + AppProperties map[string]*string `json:"appProperties"` + // SystemProperties - System properties + SystemProperties map[string]*string `json:"systemProperties"` +} + +// MarshalJSON is the custom marshaler for RoutingMessage. +func (rm RoutingMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rm.Body != nil { + objectMap["body"] = rm.Body + } + if rm.AppProperties != nil { + objectMap["appProperties"] = rm.AppProperties + } + if rm.SystemProperties != nil { + objectMap["systemProperties"] = rm.SystemProperties + } + return json.Marshal(objectMap) +} + // RoutingProperties the routing related properties of the IoT hub. See: // https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging type RoutingProperties struct { @@ -1645,3 +1925,80 @@ type StorageEndpointProperties struct { // ContainerName - The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. ContainerName *string `json:"containerName,omitempty"` } + +// TagsResource a container holding only the Tags for a resource, allowing the user to update the tags on an IoT +// Hub instance. +type TagsResource struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TagsResource. +func (tr TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// TestAllRoutesInput input for testing all routes +type TestAllRoutesInput struct { + // RoutingSource - Routing source. Possible values include: 'RoutingSourceInvalid', 'RoutingSourceDeviceMessages', 'RoutingSourceTwinChangeEvents', 'RoutingSourceDeviceLifecycleEvents', 'RoutingSourceDeviceJobLifecycleEvents' + RoutingSource RoutingSource `json:"routingSource,omitempty"` + // Message - Routing message + Message *RoutingMessage `json:"message,omitempty"` +} + +// TestAllRoutesResult result of testing all routes +type TestAllRoutesResult struct { + autorest.Response `json:"-"` + // Routes - JSON-serialized array of matched routes + Routes *[]MatchedRoute `json:"routes,omitempty"` +} + +// TestRouteInput input for testing route +type TestRouteInput struct { + // Message - Routing message + Message *RoutingMessage `json:"message,omitempty"` + // Route - Route properties + Route *RouteProperties `json:"route,omitempty"` +} + +// TestRouteResult result of testing one route +type TestRouteResult struct { + autorest.Response `json:"-"` + // Result - Result of testing route. Possible values include: 'Undefined', 'False', 'True' + Result TestResultStatus `json:"result,omitempty"` + // Details - Detailed result of testing route + Details *TestRouteResultDetails `json:"details,omitempty"` +} + +// TestRouteResultDetails detailed result of testing a route +type TestRouteResultDetails struct { + // CompilationErrors - JSON-serialized list of route compilation errors + CompilationErrors *[]RouteCompilationError `json:"compilationErrors,omitempty"` +} + +// UserSubscriptionQuota user subscription quota response +type UserSubscriptionQuota struct { + // ID - IotHub type id + ID *string `json:"id,omitempty"` + // Type - Response type + Type *string `json:"type,omitempty"` + // Unit - Unit of IotHub type + Unit *string `json:"unit,omitempty"` + // CurrentValue - Current number of IotHub type + CurrentValue *int32 `json:"currentValue,omitempty"` + // Limit - Numerical limit on IotHub type + Limit *int32 `json:"limit,omitempty"` + // Name - IotHub type + Name *Name `json:"name,omitempty"` +} + +// UserSubscriptionQuotaListResult json-serialized array of User subscription quota response +type UserSubscriptionQuotaListResult struct { + autorest.Response `json:"-"` + Value *[]UserSubscriptionQuota `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/operations.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/operations.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/operations.go index 6419b6e4a385..01395bf228a5 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/operations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/operations.go @@ -65,7 +65,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListRe // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2017-07-01" + const APIVersion = "2018-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/resourceprovidercommon.go b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/resourceprovidercommon.go new file mode 100644 index 000000000000..a80dd0c0413b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/resourceprovidercommon.go @@ -0,0 +1,102 @@ +package devices + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ResourceProviderCommonClient is the use this API to manage the IoT hubs in your Azure subscription. +type ResourceProviderCommonClient struct { + BaseClient +} + +// NewResourceProviderCommonClient creates an instance of the ResourceProviderCommonClient client. +func NewResourceProviderCommonClient(subscriptionID string) ResourceProviderCommonClient { + return NewResourceProviderCommonClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewResourceProviderCommonClientWithBaseURI creates an instance of the ResourceProviderCommonClient client. +func NewResourceProviderCommonClientWithBaseURI(baseURI string, subscriptionID string) ResourceProviderCommonClient { + return ResourceProviderCommonClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetSubscriptionQuota get the number of free and paid iot hubs in the subscription +func (client ResourceProviderCommonClient) GetSubscriptionQuota(ctx context.Context) (result UserSubscriptionQuotaListResult, err error) { + req, err := client.GetSubscriptionQuotaPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.ResourceProviderCommonClient", "GetSubscriptionQuota", nil, "Failure preparing request") + return + } + + resp, err := client.GetSubscriptionQuotaSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "devices.ResourceProviderCommonClient", "GetSubscriptionQuota", resp, "Failure sending request") + return + } + + result, err = client.GetSubscriptionQuotaResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "devices.ResourceProviderCommonClient", "GetSubscriptionQuota", resp, "Failure responding to request") + } + + return +} + +// GetSubscriptionQuotaPreparer prepares the GetSubscriptionQuota request. +func (client ResourceProviderCommonClient) GetSubscriptionQuotaPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSubscriptionQuotaSender sends the GetSubscriptionQuota request. The method will close the +// http.Response Body if it receives an error. +func (client ResourceProviderCommonClient) GetSubscriptionQuotaSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetSubscriptionQuotaResponder handles the response to the GetSubscriptionQuota request. The method always +// closes the http.Response Body. +func (client ResourceProviderCommonClient) GetSubscriptionQuotaResponder(resp *http.Response) (result UserSubscriptionQuotaListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/version.go similarity index 94% rename from vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/version.go index d03b1f2e8ac9..31c3eebda3bc 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " devices/2017-07-01" + return "Azure-SDK-For-Go/" + version.Number + " devices/2018-04-01" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/vendor.json b/vendor/vendor.json index 415157482980..6745e0b49937 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -115,8 +115,8 @@ "versionExact": "v18.0.0" }, { - "checksumSHA1": "UllFPDJZazs7Vy9wdcfKPe0r1u0=", - "path": "github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2017-07-01/devices", + "checksumSHA1": "kVhbkr1IPBMGfJbFHY4fbr/c2wU=", + "path": "github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2018-04-01/devices", "revision": "fbe7db0e3f9793ba3e5704efbab84f51436c136e", "revisionTime": "2018-07-03T19:15:42Z", "version": "=v18.0.0", diff --git a/website/docs/r/iothub.html.markdown b/website/docs/r/iothub.html.markdown index 4a680df86e6d..fa878fa6e762 100644 --- a/website/docs/r/iothub.html.markdown +++ b/website/docs/r/iothub.html.markdown @@ -52,9 +52,9 @@ The following arguments are supported: A `sku` block supports the following: -* `name` - (Required) The name of the sku. Possible values are `F1`, `S1`, `S2`, and `S3`. +* `name` - (Required) The name of the sku. Possible values are `B1`, `B2`, `B3`, `F1`, `S1`, `S2`, and `S3`. -* `tier` - (Required) The billing tier for the IoT Hub. Possible values are `Free` or `Standard`. +* `tier` - (Required) The billing tier for the IoT Hub. Possible values are `Basic`, `Free` or `Standard`. * `capacity` - (Required) The number of provisioned IoT Hub units. @@ -62,11 +62,11 @@ A `sku` block supports the following: The following attributes are exported: -* `id` - The IotHub ID. +* `id` - The ID of the IoTHub. * `hostname` - The hostname of the IotHub Resource. -* `shared_access_policy` - A list of `shared_access_policy` blocks as defined below. +* `shared_access_policy` - One or more `shared_access_policy` blocks as defined below. ---