From 2693b91108306ff1ddf5c9738ef422e16c5126f0 Mon Sep 17 00:00:00 2001 From: Matthew Frahry Date: Mon, 4 May 2020 12:08:43 -0700 Subject: [PATCH 01/14] Add servicefabricmesh package --- .../servicefabricmesh/client/client.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 azurerm/internal/services/servicefabricmesh/client/client.go diff --git a/azurerm/internal/services/servicefabricmesh/client/client.go b/azurerm/internal/services/servicefabricmesh/client/client.go new file mode 100644 index 000000000000..9b82f296b726 --- /dev/null +++ b/azurerm/internal/services/servicefabricmesh/client/client.go @@ -0,0 +1,19 @@ +package client + +import ( + "github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" +) + +type Client struct { + ApplicationClient *servicefabric.ClustersClient +} + +func NewClient(o *common.ClientOptions) *Client { + clustersClient := servicefabric.NewClustersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&clustersClient.Client, o.ResourceManagerAuthorizer) + + return &Client{ + ClustersClient: &clustersClient, + } +} From ee2e72adf7ee4d2cd484a709d4d0e645662bafcc Mon Sep 17 00:00:00 2001 From: Matthew Frahry Date: Mon, 4 May 2020 15:43:58 -0700 Subject: [PATCH 02/14] Adding tests --- azurerm/internal/clients/client.go | 3 + .../provider/required_resource_providers.go | 1 + azurerm/internal/provider/services.go | 2 + .../servicefabricmesh/client/client.go | 8 +- .../parse/service_fabric_mesh_application.go | 33 + .../service_fabric_mesh_application_test.go | 73 + .../servicefabricmesh/registration.go | 29 + ...rce_arm_service_fabric_mesh_application.go | 218 + ...rm_service_fabric_mesh_application_test.go | 112 + .../servicefabricmesh/application.go | 504 ++ .../servicefabricmesh/client.go | 52 + .../servicefabricmesh/codepackage.go | 128 + .../servicefabricmesh/gateway.go | 508 ++ .../servicefabricmesh/models.go | 4309 +++++++++++++++++ .../servicefabricmesh/network.go | 504 ++ .../servicefabricmesh/operations.go | 147 + .../servicefabricmesh/secret.go | 504 ++ .../servicefabricmesh/secretvalue.go | 486 ++ .../servicefabricmesh/service.go | 236 + .../servicefabricmesh/servicereplica.go | 240 + .../servicefabricmesh/version.go | 30 + .../servicefabricmesh/volume.go | 510 ++ vendor/modules.txt | 1 + 23 files changed, 8634 insertions(+), 4 deletions(-) create mode 100644 azurerm/internal/services/servicefabricmesh/parse/service_fabric_mesh_application.go create mode 100644 azurerm/internal/services/servicefabricmesh/parse/service_fabric_mesh_application_test.go create mode 100644 azurerm/internal/services/servicefabricmesh/registration.go create mode 100644 azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go create mode 100644 azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/application.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/codepackage.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/gateway.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/network.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/operations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/secret.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/secretvalue.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/service.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/servicereplica.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/version.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/volume.go diff --git a/azurerm/internal/clients/client.go b/azurerm/internal/clients/client.go index 091e8abbbe14..2821a25625ff 100644 --- a/azurerm/internal/clients/client.go +++ b/azurerm/internal/clients/client.go @@ -69,6 +69,7 @@ import ( sentinel "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/sentinel/client" serviceBus "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicebus/client" serviceFabric "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabric/client" + serviceFabricMesh "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabricmesh/client" signalr "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/signalr/client" sql "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/sql/client" storage "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/storage/client" @@ -148,6 +149,7 @@ type Client struct { Sentinel *sentinel.Client ServiceBus *serviceBus.Client ServiceFabric *serviceFabric.Client + ServiceFabricMesh *serviceFabricMesh.Client SignalR *signalr.Client Storage *storage.Client StreamAnalytics *streamAnalytics.Client @@ -228,6 +230,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error client.Sentinel = sentinel.NewClient(o) client.ServiceBus = serviceBus.NewClient(o) client.ServiceFabric = serviceFabric.NewClient(o) + client.ServiceFabricMesh = serviceFabricMesh.NewClient(o) client.SignalR = signalr.NewClient(o) client.Sql = sql.NewClient(o) client.Storage = storage.NewClient(o) diff --git a/azurerm/internal/provider/required_resource_providers.go b/azurerm/internal/provider/required_resource_providers.go index 9ef9c682c85e..f5f0398a1af2 100644 --- a/azurerm/internal/provider/required_resource_providers.go +++ b/azurerm/internal/provider/required_resource_providers.go @@ -70,6 +70,7 @@ func RequiredResourceProviders() map[string]struct{} { "Microsoft.SecurityInsights": {}, "Microsoft.ServiceBus": {}, "Microsoft.ServiceFabric": {}, + "Microsoft.ServiceFabricMesh": {}, "Microsoft.Sql": {}, "Microsoft.Storage": {}, "Microsoft.StorageCache": {}, diff --git a/azurerm/internal/provider/services.go b/azurerm/internal/provider/services.go index 944a42896853..8647627c9c68 100644 --- a/azurerm/internal/provider/services.go +++ b/azurerm/internal/provider/services.go @@ -65,6 +65,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/sentinel" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicebus" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabric" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabricmesh" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/signalr" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/sql" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/storage" @@ -141,6 +142,7 @@ func SupportedServices() []common.ServiceRegistration { sentinel.Registration{}, servicebus.Registration{}, servicefabric.Registration{}, + servicefabricmesh.Registration{}, signalr.Registration{}, sql.Registration{}, storage.Registration{}, diff --git a/azurerm/internal/services/servicefabricmesh/client/client.go b/azurerm/internal/services/servicefabricmesh/client/client.go index 9b82f296b726..40a2b3cf9a35 100644 --- a/azurerm/internal/services/servicefabricmesh/client/client.go +++ b/azurerm/internal/services/servicefabricmesh/client/client.go @@ -6,14 +6,14 @@ import ( ) type Client struct { - ApplicationClient *servicefabric.ClustersClient + ApplicationClient *servicefabricmesh.ApplicationClient } func NewClient(o *common.ClientOptions) *Client { - clustersClient := servicefabric.NewClustersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&clustersClient.Client, o.ResourceManagerAuthorizer) + applicationsClient := servicefabricmesh.NewApplicationClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&applicationsClient.Client, o.ResourceManagerAuthorizer) return &Client{ - ClustersClient: &clustersClient, + ApplicationClient: &applicationsClient, } } diff --git a/azurerm/internal/services/servicefabricmesh/parse/service_fabric_mesh_application.go b/azurerm/internal/services/servicefabricmesh/parse/service_fabric_mesh_application.go new file mode 100644 index 000000000000..24bfac16f4fc --- /dev/null +++ b/azurerm/internal/services/servicefabricmesh/parse/service_fabric_mesh_application.go @@ -0,0 +1,33 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type ServiceFabricMeshApplicationId struct { + ResourceGroup string + Name string +} + +func ServiceFabricMeshApplicationID(input string) (*ServiceFabricMeshApplicationId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse Service Fabric Mesh Application ID %q: %+v", input, err) + } + + cluster := ServiceFabricMeshApplicationId{ + ResourceGroup: id.ResourceGroup, + } + + if cluster.Name, err = id.PopSegment("applications"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &cluster, nil +} diff --git a/azurerm/internal/services/servicefabricmesh/parse/service_fabric_mesh_application_test.go b/azurerm/internal/services/servicefabricmesh/parse/service_fabric_mesh_application_test.go new file mode 100644 index 000000000000..4135a29ffb79 --- /dev/null +++ b/azurerm/internal/services/servicefabricmesh/parse/service_fabric_mesh_application_test.go @@ -0,0 +1,73 @@ +package parse + +import ( + "testing" +) + +func TestServiceFabricMeshApplicationId(t *testing.T) { + testData := []struct { + Name string + Input string + Expected *ServiceFabricMeshApplicationId + }{ + { + Name: "Empty", + Input: "", + Expected: nil, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Expected: nil, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Expected: nil, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Expected: nil, + }, + { + Name: "Missing Applications Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ServiceFabricMesh/applications/", + Expected: nil, + }, + { + Name: "Service Fabric Mesh Application ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ServiceFabricMesh/applications/Application1", + Expected: &ServiceFabricMeshApplicationId{ + Name: "Application1", + ResourceGroup: "resGroup1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ServiceFabricMesh/Applications/Application1", + Expected: nil, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := ServiceFabricMeshApplicationID(v.Input) + if err != nil { + if v.Expected == nil { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/servicefabricmesh/registration.go b/azurerm/internal/services/servicefabricmesh/registration.go new file mode 100644 index 000000000000..8de8aa184f03 --- /dev/null +++ b/azurerm/internal/services/servicefabricmesh/registration.go @@ -0,0 +1,29 @@ +package servicefabricmesh + +import "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + +type Registration struct{} + +// Name is the name of this Service +func (r Registration) Name() string { + return "Service Fabric Mesh" +} + +// WebsiteCategories returns a list of categories which can be used for the sidebar +func (r Registration) WebsiteCategories() []string { + return []string{ + "Service Fabric Mesh", + } +} + +// SupportedDataSources returns the supported Data Sources supported by this Service +func (r Registration) SupportedDataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{} +} + +// SupportedResources returns the supported Resources supported by this Service +func (r Registration) SupportedResources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "azurerm_service_fabric_mesh_application": resourceArmServiceFabricMeshApplication(), + } +} diff --git a/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go b/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go new file mode 100644 index 000000000000..f8b83c5e0686 --- /dev/null +++ b/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go @@ -0,0 +1,218 @@ +package servicefabricmesh + +import ( + "fmt" + "github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabricmesh/parse" + "log" + "time" + + "github.com/hashicorp/go-azure-helpers/response" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmServiceFabricMeshApplication() *schema.Resource { + return &schema.Resource{ + Create: resourceArmServiceFabricMeshApplicationCreateUpdate, + Read: resourceArmServiceFabricMeshApplicationRead, + Update: resourceArmServiceFabricMeshApplicationCreateUpdate, + Delete: resourceArmServiceFabricMeshApplicationDelete, + Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error { + _, err := parse.ServiceFabricMeshApplicationID(id) + return err + }), + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(90 * time.Minute), + Read: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(90 * time.Minute), + Delete: schema.DefaultTimeout(90 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.NoEmptyStrings, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "location": azure.SchemaLocation(), + + "service": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.NoEmptyStrings, + }, + "os_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(servicefabricmesh.Linux), + string(servicefabricmesh.Windows), + }, false), + }, + }, + }, + }, + + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.NoEmptyStrings, + }, + + "tags": tags.Schema(), + }, + } +} + +func resourceArmServiceFabricMeshApplicationCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).ServiceFabricMesh.ApplicationClient + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + resourceGroup := d.Get("resource_group_name").(string) + location := location.Normalize(d.Get("location").(string)) + t := d.Get("tags").(map[string]interface{}) + + if features.ShouldResourcesBeImported() && d.IsNewResource() { + existing, err := client.Get(ctx, resourceGroup, name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("checking for presence of existing service fabric mesh application: %+v", err) + } + } + + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_service_fabric_mesh_application", *existing.ID) + } + } + + parameters := servicefabricmesh.ApplicationResourceDescription{ + ApplicationResourceProperties: &servicefabricmesh.ApplicationResourceProperties{ + Description: utils.String(d.Get("description").(string)), + Services: expandServiceFabricMeshApplicationServices(d.Get("service").(*schema.Set).List()), + }, + Location: utils.String(location), + Tags: tags.Expand(t), + } + + if _, err := client.Create(ctx, resourceGroup, name, parameters); err != nil { + return fmt.Errorf("creating Service Fabric Mesh Application %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + resp, err := client.Get(ctx, resourceGroup, name) + if err != nil { + return fmt.Errorf("retrieving Service Fabric Mesh Application %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + d.SetId(*resp.ID) + + return resourceArmServiceFabricMeshApplicationRead(d, meta) +} + +func resourceArmServiceFabricMeshApplicationRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).ServiceFabricMesh.ApplicationClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.ServiceFabricMeshApplicationID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[INFO] Unable to find Service Fabric Mesh Application %q - removing from state", d.Id()) + d.SetId("") + return nil + } + + return fmt.Errorf("reading Service Fabric Mesh Application: %+v", err) + } + + d.Set("name", resp.Name) + d.Set("resource_group_name", id.ResourceGroup) + d.Set("location", location.NormalizeNilable(resp.Location)) + + if err := d.Set("service", flattenServiceFabricMeshApplicationServices(resp.Services)); err != nil { + return fmt.Errorf("setting `service`: %+v", err) + } + return tags.FlattenAndSet(d, resp.Tags) +} + +func resourceArmServiceFabricMeshApplicationDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).ServiceFabricMesh.ApplicationClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.ServiceFabricMeshApplicationID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Delete(ctx, id.ResourceGroup, id.Name) + if err != nil { + if !response.WasNotFound(resp.Response) { + return fmt.Errorf("deleting Service Fabric Mesh Application %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + } + + return nil +} + +func expandServiceFabricMeshApplicationServices(input []interface{}) *[]servicefabricmesh.ServiceResourceDescription { + services := make([]servicefabricmesh.ServiceResourceDescription, 0, len(input)) + + for _, serviceConfig := range input { + if serviceConfig == nil { + continue + } + config := serviceConfig.(map[string]interface{}) + + services = append(services, servicefabricmesh.ServiceResourceDescription{ + Name: utils.String(config["name"].(string)), + }) + } + + return &services +} + +func flattenServiceFabricMeshApplicationServices(input *[]servicefabricmesh.ServiceResourceDescription) []map[string]interface{} { + result := make([]map[string]interface{}, 0) + if input == nil { + return result + } + + for _, service := range *input { + attr := make(map[string]interface{}, 0) + if service.Name != nil { + attr["name"] = *service.Name + } + + result = append(result, attr) + } + + return result +} diff --git a/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go b/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go new file mode 100644 index 000000000000..48222f4ffbe0 --- /dev/null +++ b/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go @@ -0,0 +1,112 @@ +package tests + +import ( + "fmt" + "net/http" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabricmesh/parse" +) + +func TestAccAzureRMServiceFabricMeshApplication_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_service_fabric_mesh_application_test", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMServiceFabricMeshApplicationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMServiceFabricMeshApplication_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricMeshApplicationExists(data.ResourceName), + ), + }, + data.ImportStep(), + }, + }) +} + +func testCheckAzureRMServiceFabricMeshApplicationDestroy(s *terraform.State) error { + client := acceptance.AzureProvider.Meta().(*clients.Client).ServiceFabricMesh.ApplicationClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_service_fabric_mesh_application" { + continue + } + + id, err := parse.ServiceFabricMeshApplicationID(rs.Primary.ID) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + + if err != nil { + return nil + } + + if resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("Service Fabric Mesh Application still exists:\n%+v", resp) + } + } + + return nil +} + +func testCheckAzureRMServiceFabricMeshApplicationExists(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + client := acceptance.AzureProvider.Meta().(*clients.Client).ServiceFabricMesh.ApplicationClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Not found: %s", resourceName) + } + + id, err := parse.ServiceFabricMeshApplicationID(rs.Primary.ID) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + return fmt.Errorf("Bad: Get on serviceFabricMeshApplicationsClient: %+v", err) + } + + if resp.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: Service Fabric Mesh Application %q (Resource Group: %q) does not exist", id.Name, id.ResourceGroup) + } + + return nil + } +} + +func testAccAzureRMServiceFabricMeshApplication_basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_service_fabric_mesh_application" "test" { + name = "acctest-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + service { + name = "testservice1" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/application.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/application.go new file mode 100644 index 000000000000..c6363ebe7f16 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/application.go @@ -0,0 +1,504 @@ +package servicefabricmesh + +// 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" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ApplicationClient is the service Fabric Mesh Management Client +type ApplicationClient struct { + BaseClient +} + +// NewApplicationClient creates an instance of the ApplicationClient client. +func NewApplicationClient(subscriptionID string) ApplicationClient { + return NewApplicationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplicationClientWithBaseURI creates an instance of the ApplicationClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewApplicationClientWithBaseURI(baseURI string, subscriptionID string) ApplicationClient { + return ApplicationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates an application resource with the specified name, description and properties. If an application +// resource with the same name exists, then it is updated with the specified description and properties. +// Parameters: +// resourceGroupName - azure resource group name +// applicationResourceName - the identity of the application. +// applicationResourceDescription - description for creating a Application resource. +func (client ApplicationClient) Create(ctx context.Context, resourceGroupName string, applicationResourceName string, applicationResourceDescription ApplicationResourceDescription) (result ApplicationResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: applicationResourceDescription, + Constraints: []validation.Constraint{{Target: "applicationResourceDescription.ApplicationResourceProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("servicefabricmesh.ApplicationClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, applicationResourceName, applicationResourceDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ApplicationClient) CreatePreparer(ctx context.Context, resourceGroupName string, applicationResourceName string, applicationResourceDescription ApplicationResourceDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationResourceName": applicationResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/applications/{applicationResourceName}", pathParameters), + autorest.WithJSON(applicationResourceDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ApplicationClient) CreateResponder(resp *http.Response) (result ApplicationResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the application resource identified by the name. +// Parameters: +// resourceGroupName - azure resource group name +// applicationResourceName - the identity of the application. +func (client ApplicationClient) Delete(ctx context.Context, resourceGroupName string, applicationResourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, applicationResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ApplicationClient) DeletePreparer(ctx context.Context, resourceGroupName string, applicationResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationResourceName": applicationResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/applications/{applicationResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ApplicationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the information about the application resource with the given name. The information include the description +// and other properties of the application. +// Parameters: +// resourceGroupName - azure resource group name +// applicationResourceName - the identity of the application. +func (client ApplicationClient) Get(ctx context.Context, resourceGroupName string, applicationResourceName string) (result ApplicationResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, applicationResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplicationClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationResourceName": applicationResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/applications/{applicationResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplicationClient) GetResponder(resp *http.Response) (result ApplicationResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup gets the information about all application resources in a given resource group. The information +// include the description and other properties of the Application. +// Parameters: +// resourceGroupName - azure resource group name +func (client ApplicationClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ApplicationResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.ardl.Response.Response != nil { + sc = result.ardl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.ardl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.ardl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ApplicationClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/applications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ApplicationClient) ListByResourceGroupResponder(resp *http.Response) (result ApplicationResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ApplicationClient) listByResourceGroupNextResults(ctx context.Context, lastResults ApplicationResourceDescriptionList) (result ApplicationResourceDescriptionList, err error) { + req, err := lastResults.applicationResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ApplicationClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ApplicationResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription gets the information about all application resources in a given resource group. The information +// include the description and other properties of the application. +func (client ApplicationClient) ListBySubscription(ctx context.Context) (result ApplicationResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationClient.ListBySubscription") + defer func() { + sc := -1 + if result.ardl.Response.Response != nil { + sc = result.ardl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.ardl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.ardl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client ApplicationClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabricMesh/applications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client ApplicationClient) ListBySubscriptionResponder(resp *http.Response) (result ApplicationResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client ApplicationClient) listBySubscriptionNextResults(ctx context.Context, lastResults ApplicationResourceDescriptionList) (result ApplicationResourceDescriptionList, err error) { + req, err := lastResults.applicationResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ApplicationClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ApplicationClient) ListBySubscriptionComplete(ctx context.Context) (result ApplicationResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/client.go new file mode 100644 index 000000000000..f89e6dab6267 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/client.go @@ -0,0 +1,52 @@ +// Package servicefabricmesh implements the Azure ARM Servicefabricmesh service API version 2018-09-01-preview. +// +// Service Fabric Mesh Management Client +package servicefabricmesh + +// 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 ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Servicefabricmesh + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Servicefabricmesh. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/codepackage.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/codepackage.go new file mode 100644 index 000000000000..961f4b253dad --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/codepackage.go @@ -0,0 +1,128 @@ +package servicefabricmesh + +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// CodePackageClient is the service Fabric Mesh Management Client +type CodePackageClient struct { + BaseClient +} + +// NewCodePackageClient creates an instance of the CodePackageClient client. +func NewCodePackageClient(subscriptionID string) CodePackageClient { + return NewCodePackageClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCodePackageClientWithBaseURI creates an instance of the CodePackageClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCodePackageClientWithBaseURI(baseURI string, subscriptionID string) CodePackageClient { + return CodePackageClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetContainerLogs gets the logs for the container of the specified code package of the service replica. +// Parameters: +// resourceGroupName - azure resource group name +// applicationResourceName - the identity of the application. +// serviceResourceName - the identity of the service. +// replicaName - service Fabric replica name. +// codePackageName - the name of code package of the service. +// tail - number of lines to show from the end of the logs. Default is 100. +func (client CodePackageClient) GetContainerLogs(ctx context.Context, resourceGroupName string, applicationResourceName string, serviceResourceName string, replicaName string, codePackageName string, tail *int32) (result ContainerLogs, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CodePackageClient.GetContainerLogs") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetContainerLogsPreparer(ctx, resourceGroupName, applicationResourceName, serviceResourceName, replicaName, codePackageName, tail) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.CodePackageClient", "GetContainerLogs", nil, "Failure preparing request") + return + } + + resp, err := client.GetContainerLogsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.CodePackageClient", "GetContainerLogs", resp, "Failure sending request") + return + } + + result, err = client.GetContainerLogsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.CodePackageClient", "GetContainerLogs", resp, "Failure responding to request") + } + + return +} + +// GetContainerLogsPreparer prepares the GetContainerLogs request. +func (client CodePackageClient) GetContainerLogsPreparer(ctx context.Context, resourceGroupName string, applicationResourceName string, serviceResourceName string, replicaName string, codePackageName string, tail *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationResourceName": applicationResourceName, + "codePackageName": autorest.Encode("path", codePackageName), + "replicaName": replicaName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceResourceName": serviceResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if tail != nil { + queryParameters["tail"] = autorest.Encode("query", *tail) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/applications/{applicationResourceName}/services/{serviceResourceName}/replicas/{replicaName}/codePackages/{codePackageName}/logs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetContainerLogsSender sends the GetContainerLogs request. The method will close the +// http.Response Body if it receives an error. +func (client CodePackageClient) GetContainerLogsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetContainerLogsResponder handles the response to the GetContainerLogs request. The method always +// closes the http.Response Body. +func (client CodePackageClient) GetContainerLogsResponder(resp *http.Response) (result ContainerLogs, 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/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/gateway.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/gateway.go new file mode 100644 index 000000000000..1724fd8109d5 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/gateway.go @@ -0,0 +1,508 @@ +package servicefabricmesh + +// 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" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GatewayClient is the service Fabric Mesh Management Client +type GatewayClient struct { + BaseClient +} + +// NewGatewayClient creates an instance of the GatewayClient client. +func NewGatewayClient(subscriptionID string) GatewayClient { + return NewGatewayClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGatewayClientWithBaseURI creates an instance of the GatewayClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewGatewayClientWithBaseURI(baseURI string, subscriptionID string) GatewayClient { + return GatewayClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a gateway resource with the specified name, description and properties. If a gateway resource with +// the same name exists, then it is updated with the specified description and properties. Use gateway resources to +// create a gateway for public connectivity for services within your application. +// Parameters: +// resourceGroupName - azure resource group name +// gatewayResourceName - the identity of the gateway. +// gatewayResourceDescription - description for creating a Gateway resource. +func (client GatewayClient) Create(ctx context.Context, resourceGroupName string, gatewayResourceName string, gatewayResourceDescription GatewayResourceDescription) (result GatewayResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: gatewayResourceDescription, + Constraints: []validation.Constraint{{Target: "gatewayResourceDescription.GatewayResourceProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "gatewayResourceDescription.GatewayResourceProperties.SourceNetwork", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "gatewayResourceDescription.GatewayResourceProperties.DestinationNetwork", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("servicefabricmesh.GatewayClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, gatewayResourceName, gatewayResourceDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client GatewayClient) CreatePreparer(ctx context.Context, resourceGroupName string, gatewayResourceName string, gatewayResourceDescription GatewayResourceDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayResourceName": gatewayResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/gateways/{gatewayResourceName}", pathParameters), + autorest.WithJSON(gatewayResourceDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client GatewayClient) CreateResponder(resp *http.Response) (result GatewayResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the gateway resource identified by the name. +// Parameters: +// resourceGroupName - azure resource group name +// gatewayResourceName - the identity of the gateway. +func (client GatewayClient) Delete(ctx context.Context, resourceGroupName string, gatewayResourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, gatewayResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client GatewayClient) DeletePreparer(ctx context.Context, resourceGroupName string, gatewayResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayResourceName": gatewayResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/gateways/{gatewayResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client GatewayClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the information about the gateway resource with the given name. The information include the description and +// other properties of the gateway. +// Parameters: +// resourceGroupName - azure resource group name +// gatewayResourceName - the identity of the gateway. +func (client GatewayClient) Get(ctx context.Context, resourceGroupName string, gatewayResourceName string) (result GatewayResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, gatewayResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client GatewayClient) GetPreparer(ctx context.Context, resourceGroupName string, gatewayResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "gatewayResourceName": gatewayResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/gateways/{gatewayResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GatewayClient) GetResponder(resp *http.Response) (result GatewayResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup gets the information about all gateway resources in a given resource group. The information +// include the description and other properties of the Gateway. +// Parameters: +// resourceGroupName - azure resource group name +func (client GatewayClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result GatewayResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.grdl.Response.Response != nil { + sc = result.grdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.grdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.grdl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client GatewayClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/gateways", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client GatewayClient) ListByResourceGroupResponder(resp *http.Response) (result GatewayResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client GatewayClient) listByResourceGroupNextResults(ctx context.Context, lastResults GatewayResourceDescriptionList) (result GatewayResourceDescriptionList, err error) { + req, err := lastResults.gatewayResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client GatewayClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result GatewayResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription gets the information about all gateway resources in a given resource group. The information +// include the description and other properties of the gateway. +func (client GatewayClient) ListBySubscription(ctx context.Context) (result GatewayResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.ListBySubscription") + defer func() { + sc := -1 + if result.grdl.Response.Response != nil { + sc = result.grdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.grdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.grdl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client GatewayClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabricMesh/gateways", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client GatewayClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client GatewayClient) ListBySubscriptionResponder(resp *http.Response) (result GatewayResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client GatewayClient) listBySubscriptionNextResults(ctx context.Context, lastResults GatewayResourceDescriptionList) (result GatewayResourceDescriptionList, err error) { + req, err := lastResults.gatewayResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.GatewayClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client GatewayClient) ListBySubscriptionComplete(ctx context.Context) (result GatewayResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/models.go new file mode 100644 index 000000000000..6430bbdb8a11 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/models.go @@ -0,0 +1,4309 @@ +package servicefabricmesh + +// 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" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh" + +// ApplicationScopedVolumeKind enumerates the values for application scoped volume kind. +type ApplicationScopedVolumeKind string + +const ( + // ServiceFabricVolumeDisk Provides Service Fabric High Availability Volume Disk + ServiceFabricVolumeDisk ApplicationScopedVolumeKind = "ServiceFabricVolumeDisk" +) + +// PossibleApplicationScopedVolumeKindValues returns an array of possible values for the ApplicationScopedVolumeKind const type. +func PossibleApplicationScopedVolumeKindValues() []ApplicationScopedVolumeKind { + return []ApplicationScopedVolumeKind{ServiceFabricVolumeDisk} +} + +// AutoScalingMechanismKind enumerates the values for auto scaling mechanism kind. +type AutoScalingMechanismKind string + +const ( + // AddRemoveReplica Indicates that scaling should be performed by adding or removing replicas. + AddRemoveReplica AutoScalingMechanismKind = "AddRemoveReplica" +) + +// PossibleAutoScalingMechanismKindValues returns an array of possible values for the AutoScalingMechanismKind const type. +func PossibleAutoScalingMechanismKindValues() []AutoScalingMechanismKind { + return []AutoScalingMechanismKind{AddRemoveReplica} +} + +// AutoScalingMetricKind enumerates the values for auto scaling metric kind. +type AutoScalingMetricKind string + +const ( + // AutoScalingMetricKindResource Indicates that the metric is one of resources, like cpu or memory. + AutoScalingMetricKindResource AutoScalingMetricKind = "Resource" +) + +// PossibleAutoScalingMetricKindValues returns an array of possible values for the AutoScalingMetricKind const type. +func PossibleAutoScalingMetricKindValues() []AutoScalingMetricKind { + return []AutoScalingMetricKind{AutoScalingMetricKindResource} +} + +// AutoScalingResourceMetricName enumerates the values for auto scaling resource metric name. +type AutoScalingResourceMetricName string + +const ( + // CPU Indicates that the resource is CPU cores. + CPU AutoScalingResourceMetricName = "cpu" + // MemoryInGB Indicates that the resource is memory in GB. + MemoryInGB AutoScalingResourceMetricName = "memoryInGB" +) + +// PossibleAutoScalingResourceMetricNameValues returns an array of possible values for the AutoScalingResourceMetricName const type. +func PossibleAutoScalingResourceMetricNameValues() []AutoScalingResourceMetricName { + return []AutoScalingResourceMetricName{CPU, MemoryInGB} +} + +// AutoScalingTriggerKind enumerates the values for auto scaling trigger kind. +type AutoScalingTriggerKind string + +const ( + // AverageLoad Indicates that scaling should be performed based on average load of all replicas in the + // service. + AverageLoad AutoScalingTriggerKind = "AverageLoad" +) + +// PossibleAutoScalingTriggerKindValues returns an array of possible values for the AutoScalingTriggerKind const type. +func PossibleAutoScalingTriggerKindValues() []AutoScalingTriggerKind { + return []AutoScalingTriggerKind{AverageLoad} +} + +// DiagnosticsSinkKind enumerates the values for diagnostics sink kind. +type DiagnosticsSinkKind string + +const ( + // AzureInternalMonitoringPipeline Diagnostics settings for Geneva. + AzureInternalMonitoringPipeline DiagnosticsSinkKind = "AzureInternalMonitoringPipeline" + // Invalid Indicates an invalid sink kind. All Service Fabric enumerations have the invalid type. + Invalid DiagnosticsSinkKind = "Invalid" +) + +// PossibleDiagnosticsSinkKindValues returns an array of possible values for the DiagnosticsSinkKind const type. +func PossibleDiagnosticsSinkKindValues() []DiagnosticsSinkKind { + return []DiagnosticsSinkKind{AzureInternalMonitoringPipeline, Invalid} +} + +// HeaderMatchType enumerates the values for header match type. +type HeaderMatchType string + +const ( + // Exact ... + Exact HeaderMatchType = "exact" +) + +// PossibleHeaderMatchTypeValues returns an array of possible values for the HeaderMatchType const type. +func PossibleHeaderMatchTypeValues() []HeaderMatchType { + return []HeaderMatchType{Exact} +} + +// HealthState enumerates the values for health state. +type HealthState string + +const ( + // HealthStateError Indicates the health state is at an error level. Error health state should be + // investigated, as they can impact the correct functionality of the cluster. The value is 3. + HealthStateError HealthState = "Error" + // HealthStateInvalid Indicates an invalid health state. All Service Fabric enumerations have the invalid + // type. The value is zero. + HealthStateInvalid HealthState = "Invalid" + // HealthStateOk Indicates the health state is okay. The value is 1. + HealthStateOk HealthState = "Ok" + // HealthStateUnknown Indicates an unknown health status. The value is 65535. + HealthStateUnknown HealthState = "Unknown" + // HealthStateWarning Indicates the health state is at a warning level. The value is 2. + HealthStateWarning HealthState = "Warning" +) + +// PossibleHealthStateValues returns an array of possible values for the HealthState const type. +func PossibleHealthStateValues() []HealthState { + return []HealthState{HealthStateError, HealthStateInvalid, HealthStateOk, HealthStateUnknown, HealthStateWarning} +} + +// Kind enumerates the values for kind. +type Kind string + +const ( + // KindInlinedValue ... + KindInlinedValue Kind = "inlinedValue" + // KindSecretResourceProperties ... + KindSecretResourceProperties Kind = "SecretResourceProperties" + // KindSecretResourcePropertiesBase ... + KindSecretResourcePropertiesBase Kind = "SecretResourcePropertiesBase" +) + +// PossibleKindValues returns an array of possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{KindInlinedValue, KindSecretResourceProperties, KindSecretResourcePropertiesBase} +} + +// KindBasicApplicationScopedVolumeCreationParameters enumerates the values for kind basic application scoped +// volume creation parameters. +type KindBasicApplicationScopedVolumeCreationParameters string + +const ( + // KindApplicationScopedVolumeCreationParameters ... + KindApplicationScopedVolumeCreationParameters KindBasicApplicationScopedVolumeCreationParameters = "ApplicationScopedVolumeCreationParameters" + // KindServiceFabricVolumeDisk ... + KindServiceFabricVolumeDisk KindBasicApplicationScopedVolumeCreationParameters = "ServiceFabricVolumeDisk" +) + +// PossibleKindBasicApplicationScopedVolumeCreationParametersValues returns an array of possible values for the KindBasicApplicationScopedVolumeCreationParameters const type. +func PossibleKindBasicApplicationScopedVolumeCreationParametersValues() []KindBasicApplicationScopedVolumeCreationParameters { + return []KindBasicApplicationScopedVolumeCreationParameters{KindApplicationScopedVolumeCreationParameters, KindServiceFabricVolumeDisk} +} + +// KindBasicAutoScalingMechanism enumerates the values for kind basic auto scaling mechanism. +type KindBasicAutoScalingMechanism string + +const ( + // KindAddRemoveReplica ... + KindAddRemoveReplica KindBasicAutoScalingMechanism = "AddRemoveReplica" + // KindAutoScalingMechanism ... + KindAutoScalingMechanism KindBasicAutoScalingMechanism = "AutoScalingMechanism" +) + +// PossibleKindBasicAutoScalingMechanismValues returns an array of possible values for the KindBasicAutoScalingMechanism const type. +func PossibleKindBasicAutoScalingMechanismValues() []KindBasicAutoScalingMechanism { + return []KindBasicAutoScalingMechanism{KindAddRemoveReplica, KindAutoScalingMechanism} +} + +// KindBasicAutoScalingMetric enumerates the values for kind basic auto scaling metric. +type KindBasicAutoScalingMetric string + +const ( + // KindAutoScalingMetric ... + KindAutoScalingMetric KindBasicAutoScalingMetric = "AutoScalingMetric" + // KindResource ... + KindResource KindBasicAutoScalingMetric = "Resource" +) + +// PossibleKindBasicAutoScalingMetricValues returns an array of possible values for the KindBasicAutoScalingMetric const type. +func PossibleKindBasicAutoScalingMetricValues() []KindBasicAutoScalingMetric { + return []KindBasicAutoScalingMetric{KindAutoScalingMetric, KindResource} +} + +// KindBasicAutoScalingTrigger enumerates the values for kind basic auto scaling trigger. +type KindBasicAutoScalingTrigger string + +const ( + // KindAutoScalingTrigger ... + KindAutoScalingTrigger KindBasicAutoScalingTrigger = "AutoScalingTrigger" + // KindAverageLoad ... + KindAverageLoad KindBasicAutoScalingTrigger = "AverageLoad" +) + +// PossibleKindBasicAutoScalingTriggerValues returns an array of possible values for the KindBasicAutoScalingTrigger const type. +func PossibleKindBasicAutoScalingTriggerValues() []KindBasicAutoScalingTrigger { + return []KindBasicAutoScalingTrigger{KindAutoScalingTrigger, KindAverageLoad} +} + +// KindBasicDiagnosticsSinkProperties enumerates the values for kind basic diagnostics sink properties. +type KindBasicDiagnosticsSinkProperties string + +const ( + // KindAzureInternalMonitoringPipeline ... + KindAzureInternalMonitoringPipeline KindBasicDiagnosticsSinkProperties = "AzureInternalMonitoringPipeline" + // KindDiagnosticsSinkProperties ... + KindDiagnosticsSinkProperties KindBasicDiagnosticsSinkProperties = "DiagnosticsSinkProperties" +) + +// PossibleKindBasicDiagnosticsSinkPropertiesValues returns an array of possible values for the KindBasicDiagnosticsSinkProperties const type. +func PossibleKindBasicDiagnosticsSinkPropertiesValues() []KindBasicDiagnosticsSinkProperties { + return []KindBasicDiagnosticsSinkProperties{KindAzureInternalMonitoringPipeline, KindDiagnosticsSinkProperties} +} + +// KindBasicNetworkResourcePropertiesBase enumerates the values for kind basic network resource properties +// base. +type KindBasicNetworkResourcePropertiesBase string + +const ( + // KindLocal ... + KindLocal KindBasicNetworkResourcePropertiesBase = "Local" + // KindNetworkResourceProperties ... + KindNetworkResourceProperties KindBasicNetworkResourcePropertiesBase = "NetworkResourceProperties" + // KindNetworkResourcePropertiesBase ... + KindNetworkResourcePropertiesBase KindBasicNetworkResourcePropertiesBase = "NetworkResourcePropertiesBase" +) + +// PossibleKindBasicNetworkResourcePropertiesBaseValues returns an array of possible values for the KindBasicNetworkResourcePropertiesBase const type. +func PossibleKindBasicNetworkResourcePropertiesBaseValues() []KindBasicNetworkResourcePropertiesBase { + return []KindBasicNetworkResourcePropertiesBase{KindLocal, KindNetworkResourceProperties, KindNetworkResourcePropertiesBase} +} + +// NetworkKind enumerates the values for network kind. +type NetworkKind string + +const ( + // Local Indicates a container network local to a single Service Fabric cluster. The value is 1. + Local NetworkKind = "Local" +) + +// PossibleNetworkKindValues returns an array of possible values for the NetworkKind const type. +func PossibleNetworkKindValues() []NetworkKind { + return []NetworkKind{Local} +} + +// OperatingSystemType enumerates the values for operating system type. +type OperatingSystemType string + +const ( + // Linux The required operating system is Linux. + Linux OperatingSystemType = "Linux" + // Windows The required operating system is Windows. + Windows OperatingSystemType = "Windows" +) + +// PossibleOperatingSystemTypeValues returns an array of possible values for the OperatingSystemType const type. +func PossibleOperatingSystemTypeValues() []OperatingSystemType { + return []OperatingSystemType{Linux, Windows} +} + +// ResourceStatus enumerates the values for resource status. +type ResourceStatus string + +const ( + // Creating Indicates the resource is being created. The value is 3. + Creating ResourceStatus = "Creating" + // Deleting Indicates the resource is being deleted. The value is 4. + Deleting ResourceStatus = "Deleting" + // Failed Indicates the resource is not functional due to persistent failures. See statusDetails property + // for more details. The value is 5. + Failed ResourceStatus = "Failed" + // Ready Indicates the resource is ready. The value is 1. + Ready ResourceStatus = "Ready" + // Unknown Indicates the resource status is unknown. The value is zero. + Unknown ResourceStatus = "Unknown" + // Upgrading Indicates the resource is upgrading. The value is 2. + Upgrading ResourceStatus = "Upgrading" +) + +// PossibleResourceStatusValues returns an array of possible values for the ResourceStatus const type. +func PossibleResourceStatusValues() []ResourceStatus { + return []ResourceStatus{Creating, Deleting, Failed, Ready, Unknown, Upgrading} +} + +// SecretKind enumerates the values for secret kind. +type SecretKind string + +const ( + // InlinedValue A simple secret resource whose plaintext value is provided by the user. + InlinedValue SecretKind = "inlinedValue" +) + +// PossibleSecretKindValues returns an array of possible values for the SecretKind const type. +func PossibleSecretKindValues() []SecretKind { + return []SecretKind{InlinedValue} +} + +// SizeTypes enumerates the values for size types. +type SizeTypes string + +const ( + // Large ... + Large SizeTypes = "Large" + // Medium ... + Medium SizeTypes = "Medium" + // Small ... + Small SizeTypes = "Small" +) + +// PossibleSizeTypesValues returns an array of possible values for the SizeTypes const type. +func PossibleSizeTypesValues() []SizeTypes { + return []SizeTypes{Large, Medium, Small} +} + +// VolumeProvider enumerates the values for volume provider. +type VolumeProvider string + +const ( + // SFAzureFile Provides volumes that are backed by Azure Files. + SFAzureFile VolumeProvider = "SFAzureFile" +) + +// PossibleVolumeProviderValues returns an array of possible values for the VolumeProvider const type. +func PossibleVolumeProviderValues() []VolumeProvider { + return []VolumeProvider{SFAzureFile} +} + +// AddRemoveReplicaScalingMechanism describes the horizontal auto scaling mechanism that adds or removes +// replicas (containers or container groups). +type AddRemoveReplicaScalingMechanism struct { + // MinCount - Minimum number of containers (scale down won't be performed below this number). + MinCount *int32 `json:"minCount,omitempty"` + // MaxCount - Maximum number of containers (scale up won't be performed above this number). + MaxCount *int32 `json:"maxCount,omitempty"` + // ScaleIncrement - Each time auto scaling is performed, this number of containers will be added or removed. + ScaleIncrement *int32 `json:"scaleIncrement,omitempty"` + // Kind - Possible values include: 'KindAutoScalingMechanism', 'KindAddRemoveReplica' + Kind KindBasicAutoScalingMechanism `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for AddRemoveReplicaScalingMechanism. +func (arrsm AddRemoveReplicaScalingMechanism) MarshalJSON() ([]byte, error) { + arrsm.Kind = KindAddRemoveReplica + objectMap := make(map[string]interface{}) + if arrsm.MinCount != nil { + objectMap["minCount"] = arrsm.MinCount + } + if arrsm.MaxCount != nil { + objectMap["maxCount"] = arrsm.MaxCount + } + if arrsm.ScaleIncrement != nil { + objectMap["scaleIncrement"] = arrsm.ScaleIncrement + } + if arrsm.Kind != "" { + objectMap["kind"] = arrsm.Kind + } + return json.Marshal(objectMap) +} + +// AsAddRemoveReplicaScalingMechanism is the BasicAutoScalingMechanism implementation for AddRemoveReplicaScalingMechanism. +func (arrsm AddRemoveReplicaScalingMechanism) AsAddRemoveReplicaScalingMechanism() (*AddRemoveReplicaScalingMechanism, bool) { + return &arrsm, true +} + +// AsAutoScalingMechanism is the BasicAutoScalingMechanism implementation for AddRemoveReplicaScalingMechanism. +func (arrsm AddRemoveReplicaScalingMechanism) AsAutoScalingMechanism() (*AutoScalingMechanism, bool) { + return nil, false +} + +// AsBasicAutoScalingMechanism is the BasicAutoScalingMechanism implementation for AddRemoveReplicaScalingMechanism. +func (arrsm AddRemoveReplicaScalingMechanism) AsBasicAutoScalingMechanism() (BasicAutoScalingMechanism, bool) { + return &arrsm, true +} + +// ApplicationProperties describes properties of a application resource. +type ApplicationProperties struct { + // Description - User readable description of the application. + Description *string `json:"description,omitempty"` + // Services - Describes the services in the application. This property is used to create or modify services of the application. On get only the name of the service is returned. The service description can be obtained by querying for the service resource. + Services *[]ServiceResourceDescription `json:"services,omitempty"` + // Diagnostics - Describes the diagnostics definition and usage for an application resource. + Diagnostics *DiagnosticsDescription `json:"diagnostics,omitempty"` + // DebugParams - Internal - used by Visual Studio to setup the debugging session on the local development environment. + DebugParams *string `json:"debugParams,omitempty"` + // ServiceNames - READ-ONLY; Names of the services in the application. + ServiceNames *[]string `json:"serviceNames,omitempty"` + // Status - READ-ONLY; Status of the application. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the application. + StatusDetails *string `json:"statusDetails,omitempty"` + // HealthState - READ-ONLY; Describes the health state of an application resource. Possible values include: 'HealthStateInvalid', 'HealthStateOk', 'HealthStateWarning', 'HealthStateError', 'HealthStateUnknown' + HealthState HealthState `json:"healthState,omitempty"` + // UnhealthyEvaluation - READ-ONLY; When the application's health state is not 'Ok', this additional details from service fabric Health Manager for the user to know why the application is marked unhealthy. + UnhealthyEvaluation *string `json:"unhealthyEvaluation,omitempty"` +} + +// ApplicationResourceDescription this type describes an application resource. +type ApplicationResourceDescription struct { + autorest.Response `json:"-"` + // ApplicationResourceProperties - This type describes properties of an application resource. + *ApplicationResourceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationResourceDescription. +func (ard ApplicationResourceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ard.ApplicationResourceProperties != nil { + objectMap["properties"] = ard.ApplicationResourceProperties + } + if ard.Tags != nil { + objectMap["tags"] = ard.Tags + } + if ard.Location != nil { + objectMap["location"] = ard.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationResourceDescription struct. +func (ard *ApplicationResourceDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var applicationResourceProperties ApplicationResourceProperties + err = json.Unmarshal(*v, &applicationResourceProperties) + if err != nil { + return err + } + ard.ApplicationResourceProperties = &applicationResourceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ard.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ard.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ard.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ard.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ard.Type = &typeVar + } + } + } + + return nil +} + +// ApplicationResourceDescriptionList a pageable list of application resources. +type ApplicationResourceDescriptionList struct { + autorest.Response `json:"-"` + // Value - One page of the list. + Value *[]ApplicationResourceDescription `json:"value,omitempty"` + // NextLink - URI to fetch the next page of the list. + NextLink *string `json:"nextLink,omitempty"` +} + +// ApplicationResourceDescriptionListIterator provides access to a complete listing of +// ApplicationResourceDescription values. +type ApplicationResourceDescriptionListIterator struct { + i int + page ApplicationResourceDescriptionListPage +} + +// NextWithContext 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 *ApplicationResourceDescriptionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationResourceDescriptionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ApplicationResourceDescriptionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ApplicationResourceDescriptionListIterator) 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 ApplicationResourceDescriptionListIterator) Response() ApplicationResourceDescriptionList { + 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 ApplicationResourceDescriptionListIterator) Value() ApplicationResourceDescription { + if !iter.page.NotDone() { + return ApplicationResourceDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ApplicationResourceDescriptionListIterator type. +func NewApplicationResourceDescriptionListIterator(page ApplicationResourceDescriptionListPage) ApplicationResourceDescriptionListIterator { + return ApplicationResourceDescriptionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ardl ApplicationResourceDescriptionList) IsEmpty() bool { + return ardl.Value == nil || len(*ardl.Value) == 0 +} + +// applicationResourceDescriptionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ardl ApplicationResourceDescriptionList) applicationResourceDescriptionListPreparer(ctx context.Context) (*http.Request, error) { + if ardl.NextLink == nil || len(to.String(ardl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ardl.NextLink))) +} + +// ApplicationResourceDescriptionListPage contains a page of ApplicationResourceDescription values. +type ApplicationResourceDescriptionListPage struct { + fn func(context.Context, ApplicationResourceDescriptionList) (ApplicationResourceDescriptionList, error) + ardl ApplicationResourceDescriptionList +} + +// NextWithContext 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 *ApplicationResourceDescriptionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ApplicationResourceDescriptionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.ardl) + if err != nil { + return err + } + page.ardl = next + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ApplicationResourceDescriptionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ApplicationResourceDescriptionListPage) NotDone() bool { + return !page.ardl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ApplicationResourceDescriptionListPage) Response() ApplicationResourceDescriptionList { + return page.ardl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ApplicationResourceDescriptionListPage) Values() []ApplicationResourceDescription { + if page.ardl.IsEmpty() { + return nil + } + return *page.ardl.Value +} + +// Creates a new instance of the ApplicationResourceDescriptionListPage type. +func NewApplicationResourceDescriptionListPage(getNextPage func(context.Context, ApplicationResourceDescriptionList) (ApplicationResourceDescriptionList, error)) ApplicationResourceDescriptionListPage { + return ApplicationResourceDescriptionListPage{fn: getNextPage} +} + +// ApplicationResourceProperties this type describes properties of an application resource. +type ApplicationResourceProperties struct { + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Description - User readable description of the application. + Description *string `json:"description,omitempty"` + // Services - Describes the services in the application. This property is used to create or modify services of the application. On get only the name of the service is returned. The service description can be obtained by querying for the service resource. + Services *[]ServiceResourceDescription `json:"services,omitempty"` + // Diagnostics - Describes the diagnostics definition and usage for an application resource. + Diagnostics *DiagnosticsDescription `json:"diagnostics,omitempty"` + // DebugParams - Internal - used by Visual Studio to setup the debugging session on the local development environment. + DebugParams *string `json:"debugParams,omitempty"` + // ServiceNames - READ-ONLY; Names of the services in the application. + ServiceNames *[]string `json:"serviceNames,omitempty"` + // Status - READ-ONLY; Status of the application. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the application. + StatusDetails *string `json:"statusDetails,omitempty"` + // HealthState - READ-ONLY; Describes the health state of an application resource. Possible values include: 'HealthStateInvalid', 'HealthStateOk', 'HealthStateWarning', 'HealthStateError', 'HealthStateUnknown' + HealthState HealthState `json:"healthState,omitempty"` + // UnhealthyEvaluation - READ-ONLY; When the application's health state is not 'Ok', this additional details from service fabric Health Manager for the user to know why the application is marked unhealthy. + UnhealthyEvaluation *string `json:"unhealthyEvaluation,omitempty"` +} + +// ApplicationScopedVolume describes a volume whose lifetime is scoped to the application's lifetime. +type ApplicationScopedVolume struct { + // CreationParameters - Describes parameters for creating application-scoped volumes. + CreationParameters BasicApplicationScopedVolumeCreationParameters `json:"creationParameters,omitempty"` + // Name - Name of the volume being referenced. + Name *string `json:"name,omitempty"` + // ReadOnly - The flag indicating whether the volume is read only. Default is 'false'. + ReadOnly *bool `json:"readOnly,omitempty"` + // DestinationPath - The path within the container at which the volume should be mounted. Only valid path characters are allowed. + DestinationPath *string `json:"destinationPath,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationScopedVolume struct. +func (asv *ApplicationScopedVolume) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "creationParameters": + if v != nil { + creationParameters, err := unmarshalBasicApplicationScopedVolumeCreationParameters(*v) + if err != nil { + return err + } + asv.CreationParameters = creationParameters + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + asv.Name = &name + } + case "readOnly": + if v != nil { + var readOnly bool + err = json.Unmarshal(*v, &readOnly) + if err != nil { + return err + } + asv.ReadOnly = &readOnly + } + case "destinationPath": + if v != nil { + var destinationPath string + err = json.Unmarshal(*v, &destinationPath) + if err != nil { + return err + } + asv.DestinationPath = &destinationPath + } + } + } + + return nil +} + +// BasicApplicationScopedVolumeCreationParameters describes parameters for creating application-scoped volumes. +type BasicApplicationScopedVolumeCreationParameters interface { + AsApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk() (*ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk, bool) + AsApplicationScopedVolumeCreationParameters() (*ApplicationScopedVolumeCreationParameters, bool) +} + +// ApplicationScopedVolumeCreationParameters describes parameters for creating application-scoped volumes. +type ApplicationScopedVolumeCreationParameters struct { + // Description - User readable description of the volume. + Description *string `json:"description,omitempty"` + // Kind - Possible values include: 'KindApplicationScopedVolumeCreationParameters', 'KindServiceFabricVolumeDisk' + Kind KindBasicApplicationScopedVolumeCreationParameters `json:"kind,omitempty"` +} + +func unmarshalBasicApplicationScopedVolumeCreationParameters(body []byte) (BasicApplicationScopedVolumeCreationParameters, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindServiceFabricVolumeDisk): + var asvcpsfvd ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk + err := json.Unmarshal(body, &asvcpsfvd) + return asvcpsfvd, err + default: + var asvcp ApplicationScopedVolumeCreationParameters + err := json.Unmarshal(body, &asvcp) + return asvcp, err + } +} +func unmarshalBasicApplicationScopedVolumeCreationParametersArray(body []byte) ([]BasicApplicationScopedVolumeCreationParameters, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + asvcpArray := make([]BasicApplicationScopedVolumeCreationParameters, len(rawMessages)) + + for index, rawMessage := range rawMessages { + asvcp, err := unmarshalBasicApplicationScopedVolumeCreationParameters(*rawMessage) + if err != nil { + return nil, err + } + asvcpArray[index] = asvcp + } + return asvcpArray, nil +} + +// MarshalJSON is the custom marshaler for ApplicationScopedVolumeCreationParameters. +func (asvcp ApplicationScopedVolumeCreationParameters) MarshalJSON() ([]byte, error) { + asvcp.Kind = KindApplicationScopedVolumeCreationParameters + objectMap := make(map[string]interface{}) + if asvcp.Description != nil { + objectMap["description"] = asvcp.Description + } + if asvcp.Kind != "" { + objectMap["kind"] = asvcp.Kind + } + return json.Marshal(objectMap) +} + +// AsApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk is the BasicApplicationScopedVolumeCreationParameters implementation for ApplicationScopedVolumeCreationParameters. +func (asvcp ApplicationScopedVolumeCreationParameters) AsApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk() (*ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk, bool) { + return nil, false +} + +// AsApplicationScopedVolumeCreationParameters is the BasicApplicationScopedVolumeCreationParameters implementation for ApplicationScopedVolumeCreationParameters. +func (asvcp ApplicationScopedVolumeCreationParameters) AsApplicationScopedVolumeCreationParameters() (*ApplicationScopedVolumeCreationParameters, bool) { + return &asvcp, true +} + +// AsBasicApplicationScopedVolumeCreationParameters is the BasicApplicationScopedVolumeCreationParameters implementation for ApplicationScopedVolumeCreationParameters. +func (asvcp ApplicationScopedVolumeCreationParameters) AsBasicApplicationScopedVolumeCreationParameters() (BasicApplicationScopedVolumeCreationParameters, bool) { + return &asvcp, true +} + +// ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk describes parameters for creating +// application-scoped volumes provided by Service Fabric Volume Disks +type ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk struct { + // SizeDisk - Volume size. Possible values include: 'Small', 'Medium', 'Large' + SizeDisk SizeTypes `json:"sizeDisk,omitempty"` + // Description - User readable description of the volume. + Description *string `json:"description,omitempty"` + // Kind - Possible values include: 'KindApplicationScopedVolumeCreationParameters', 'KindServiceFabricVolumeDisk' + Kind KindBasicApplicationScopedVolumeCreationParameters `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk. +func (asvcpsfvd ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk) MarshalJSON() ([]byte, error) { + asvcpsfvd.Kind = KindServiceFabricVolumeDisk + objectMap := make(map[string]interface{}) + if asvcpsfvd.SizeDisk != "" { + objectMap["sizeDisk"] = asvcpsfvd.SizeDisk + } + if asvcpsfvd.Description != nil { + objectMap["description"] = asvcpsfvd.Description + } + if asvcpsfvd.Kind != "" { + objectMap["kind"] = asvcpsfvd.Kind + } + return json.Marshal(objectMap) +} + +// AsApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk is the BasicApplicationScopedVolumeCreationParameters implementation for ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk. +func (asvcpsfvd ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk) AsApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk() (*ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk, bool) { + return &asvcpsfvd, true +} + +// AsApplicationScopedVolumeCreationParameters is the BasicApplicationScopedVolumeCreationParameters implementation for ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk. +func (asvcpsfvd ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk) AsApplicationScopedVolumeCreationParameters() (*ApplicationScopedVolumeCreationParameters, bool) { + return nil, false +} + +// AsBasicApplicationScopedVolumeCreationParameters is the BasicApplicationScopedVolumeCreationParameters implementation for ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk. +func (asvcpsfvd ApplicationScopedVolumeCreationParametersServiceFabricVolumeDisk) AsBasicApplicationScopedVolumeCreationParameters() (BasicApplicationScopedVolumeCreationParameters, bool) { + return &asvcpsfvd, true +} + +// BasicAutoScalingMechanism describes the mechanism for performing auto scaling operation. Derived classes will +// describe the actual mechanism. +type BasicAutoScalingMechanism interface { + AsAddRemoveReplicaScalingMechanism() (*AddRemoveReplicaScalingMechanism, bool) + AsAutoScalingMechanism() (*AutoScalingMechanism, bool) +} + +// AutoScalingMechanism describes the mechanism for performing auto scaling operation. Derived classes will +// describe the actual mechanism. +type AutoScalingMechanism struct { + // Kind - Possible values include: 'KindAutoScalingMechanism', 'KindAddRemoveReplica' + Kind KindBasicAutoScalingMechanism `json:"kind,omitempty"` +} + +func unmarshalBasicAutoScalingMechanism(body []byte) (BasicAutoScalingMechanism, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindAddRemoveReplica): + var arrsm AddRemoveReplicaScalingMechanism + err := json.Unmarshal(body, &arrsm) + return arrsm, err + default: + var asm AutoScalingMechanism + err := json.Unmarshal(body, &asm) + return asm, err + } +} +func unmarshalBasicAutoScalingMechanismArray(body []byte) ([]BasicAutoScalingMechanism, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + asmArray := make([]BasicAutoScalingMechanism, len(rawMessages)) + + for index, rawMessage := range rawMessages { + asm, err := unmarshalBasicAutoScalingMechanism(*rawMessage) + if err != nil { + return nil, err + } + asmArray[index] = asm + } + return asmArray, nil +} + +// MarshalJSON is the custom marshaler for AutoScalingMechanism. +func (asm AutoScalingMechanism) MarshalJSON() ([]byte, error) { + asm.Kind = KindAutoScalingMechanism + objectMap := make(map[string]interface{}) + if asm.Kind != "" { + objectMap["kind"] = asm.Kind + } + return json.Marshal(objectMap) +} + +// AsAddRemoveReplicaScalingMechanism is the BasicAutoScalingMechanism implementation for AutoScalingMechanism. +func (asm AutoScalingMechanism) AsAddRemoveReplicaScalingMechanism() (*AddRemoveReplicaScalingMechanism, bool) { + return nil, false +} + +// AsAutoScalingMechanism is the BasicAutoScalingMechanism implementation for AutoScalingMechanism. +func (asm AutoScalingMechanism) AsAutoScalingMechanism() (*AutoScalingMechanism, bool) { + return &asm, true +} + +// AsBasicAutoScalingMechanism is the BasicAutoScalingMechanism implementation for AutoScalingMechanism. +func (asm AutoScalingMechanism) AsBasicAutoScalingMechanism() (BasicAutoScalingMechanism, bool) { + return &asm, true +} + +// BasicAutoScalingMetric describes the metric that is used for triggering auto scaling operation. Derived classes will +// describe resources or metrics. +type BasicAutoScalingMetric interface { + AsAutoScalingResourceMetric() (*AutoScalingResourceMetric, bool) + AsAutoScalingMetric() (*AutoScalingMetric, bool) +} + +// AutoScalingMetric describes the metric that is used for triggering auto scaling operation. Derived classes +// will describe resources or metrics. +type AutoScalingMetric struct { + // Kind - Possible values include: 'KindAutoScalingMetric', 'KindResource' + Kind KindBasicAutoScalingMetric `json:"kind,omitempty"` +} + +func unmarshalBasicAutoScalingMetric(body []byte) (BasicAutoScalingMetric, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindResource): + var asrm AutoScalingResourceMetric + err := json.Unmarshal(body, &asrm) + return asrm, err + default: + var asm AutoScalingMetric + err := json.Unmarshal(body, &asm) + return asm, err + } +} +func unmarshalBasicAutoScalingMetricArray(body []byte) ([]BasicAutoScalingMetric, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + asmArray := make([]BasicAutoScalingMetric, len(rawMessages)) + + for index, rawMessage := range rawMessages { + asm, err := unmarshalBasicAutoScalingMetric(*rawMessage) + if err != nil { + return nil, err + } + asmArray[index] = asm + } + return asmArray, nil +} + +// MarshalJSON is the custom marshaler for AutoScalingMetric. +func (asm AutoScalingMetric) MarshalJSON() ([]byte, error) { + asm.Kind = KindAutoScalingMetric + objectMap := make(map[string]interface{}) + if asm.Kind != "" { + objectMap["kind"] = asm.Kind + } + return json.Marshal(objectMap) +} + +// AsAutoScalingResourceMetric is the BasicAutoScalingMetric implementation for AutoScalingMetric. +func (asm AutoScalingMetric) AsAutoScalingResourceMetric() (*AutoScalingResourceMetric, bool) { + return nil, false +} + +// AsAutoScalingMetric is the BasicAutoScalingMetric implementation for AutoScalingMetric. +func (asm AutoScalingMetric) AsAutoScalingMetric() (*AutoScalingMetric, bool) { + return &asm, true +} + +// AsBasicAutoScalingMetric is the BasicAutoScalingMetric implementation for AutoScalingMetric. +func (asm AutoScalingMetric) AsBasicAutoScalingMetric() (BasicAutoScalingMetric, bool) { + return &asm, true +} + +// AutoScalingPolicy describes the auto scaling policy +type AutoScalingPolicy struct { + // Name - The name of the auto scaling policy. + Name *string `json:"name,omitempty"` + // Trigger - Determines when auto scaling operation will be invoked. + Trigger BasicAutoScalingTrigger `json:"trigger,omitempty"` + // Mechanism - The mechanism that is used to scale when auto scaling operation is invoked. + Mechanism BasicAutoScalingMechanism `json:"mechanism,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for AutoScalingPolicy struct. +func (asp *AutoScalingPolicy) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + asp.Name = &name + } + case "trigger": + if v != nil { + trigger, err := unmarshalBasicAutoScalingTrigger(*v) + if err != nil { + return err + } + asp.Trigger = trigger + } + case "mechanism": + if v != nil { + mechanism, err := unmarshalBasicAutoScalingMechanism(*v) + if err != nil { + return err + } + asp.Mechanism = mechanism + } + } + } + + return nil +} + +// AutoScalingResourceMetric describes the resource that is used for triggering auto scaling. +type AutoScalingResourceMetric struct { + // Name - Name of the resource. Possible values include: 'CPU', 'MemoryInGB' + Name AutoScalingResourceMetricName `json:"name,omitempty"` + // Kind - Possible values include: 'KindAutoScalingMetric', 'KindResource' + Kind KindBasicAutoScalingMetric `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for AutoScalingResourceMetric. +func (asrm AutoScalingResourceMetric) MarshalJSON() ([]byte, error) { + asrm.Kind = KindResource + objectMap := make(map[string]interface{}) + if asrm.Name != "" { + objectMap["name"] = asrm.Name + } + if asrm.Kind != "" { + objectMap["kind"] = asrm.Kind + } + return json.Marshal(objectMap) +} + +// AsAutoScalingResourceMetric is the BasicAutoScalingMetric implementation for AutoScalingResourceMetric. +func (asrm AutoScalingResourceMetric) AsAutoScalingResourceMetric() (*AutoScalingResourceMetric, bool) { + return &asrm, true +} + +// AsAutoScalingMetric is the BasicAutoScalingMetric implementation for AutoScalingResourceMetric. +func (asrm AutoScalingResourceMetric) AsAutoScalingMetric() (*AutoScalingMetric, bool) { + return nil, false +} + +// AsBasicAutoScalingMetric is the BasicAutoScalingMetric implementation for AutoScalingResourceMetric. +func (asrm AutoScalingResourceMetric) AsBasicAutoScalingMetric() (BasicAutoScalingMetric, bool) { + return &asrm, true +} + +// BasicAutoScalingTrigger describes the trigger for performing auto scaling operation. +type BasicAutoScalingTrigger interface { + AsAverageLoadScalingTrigger() (*AverageLoadScalingTrigger, bool) + AsAutoScalingTrigger() (*AutoScalingTrigger, bool) +} + +// AutoScalingTrigger describes the trigger for performing auto scaling operation. +type AutoScalingTrigger struct { + // Kind - Possible values include: 'KindAutoScalingTrigger', 'KindAverageLoad' + Kind KindBasicAutoScalingTrigger `json:"kind,omitempty"` +} + +func unmarshalBasicAutoScalingTrigger(body []byte) (BasicAutoScalingTrigger, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindAverageLoad): + var alst AverageLoadScalingTrigger + err := json.Unmarshal(body, &alst) + return alst, err + default: + var astVar AutoScalingTrigger + err := json.Unmarshal(body, &astVar) + return astVar, err + } +} +func unmarshalBasicAutoScalingTriggerArray(body []byte) ([]BasicAutoScalingTrigger, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + astVarArray := make([]BasicAutoScalingTrigger, len(rawMessages)) + + for index, rawMessage := range rawMessages { + astVar, err := unmarshalBasicAutoScalingTrigger(*rawMessage) + if err != nil { + return nil, err + } + astVarArray[index] = astVar + } + return astVarArray, nil +} + +// MarshalJSON is the custom marshaler for AutoScalingTrigger. +func (astVar AutoScalingTrigger) MarshalJSON() ([]byte, error) { + astVar.Kind = KindAutoScalingTrigger + objectMap := make(map[string]interface{}) + if astVar.Kind != "" { + objectMap["kind"] = astVar.Kind + } + return json.Marshal(objectMap) +} + +// AsAverageLoadScalingTrigger is the BasicAutoScalingTrigger implementation for AutoScalingTrigger. +func (astVar AutoScalingTrigger) AsAverageLoadScalingTrigger() (*AverageLoadScalingTrigger, bool) { + return nil, false +} + +// AsAutoScalingTrigger is the BasicAutoScalingTrigger implementation for AutoScalingTrigger. +func (astVar AutoScalingTrigger) AsAutoScalingTrigger() (*AutoScalingTrigger, bool) { + return &astVar, true +} + +// AsBasicAutoScalingTrigger is the BasicAutoScalingTrigger implementation for AutoScalingTrigger. +func (astVar AutoScalingTrigger) AsBasicAutoScalingTrigger() (BasicAutoScalingTrigger, bool) { + return &astVar, true +} + +// AvailableOperationDisplay an operation available at the listed Azure resource provider. +type AvailableOperationDisplay struct { + // Provider - Name of the operation provider. + Provider *string `json:"provider,omitempty"` + // Resource - Name of the resource on which the operation is available. + Resource *string `json:"resource,omitempty"` + // Operation - Name of the available operation. + Operation *string `json:"operation,omitempty"` + // Description - Description of the available operation. + Description *string `json:"description,omitempty"` +} + +// AverageLoadScalingTrigger describes the average load trigger used for auto scaling. +type AverageLoadScalingTrigger struct { + // Metric - Description of the metric that is used for scaling. + Metric BasicAutoScalingMetric `json:"metric,omitempty"` + // LowerLoadThreshold - Lower load threshold (if average load is below this threshold, service will scale down). + LowerLoadThreshold *float64 `json:"lowerLoadThreshold,omitempty"` + // UpperLoadThreshold - Upper load threshold (if average load is above this threshold, service will scale up). + UpperLoadThreshold *float64 `json:"upperLoadThreshold,omitempty"` + // ScaleIntervalInSeconds - Scale interval that indicates how often will this trigger be checked. + ScaleIntervalInSeconds *int32 `json:"scaleIntervalInSeconds,omitempty"` + // Kind - Possible values include: 'KindAutoScalingTrigger', 'KindAverageLoad' + Kind KindBasicAutoScalingTrigger `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for AverageLoadScalingTrigger. +func (alst AverageLoadScalingTrigger) MarshalJSON() ([]byte, error) { + alst.Kind = KindAverageLoad + objectMap := make(map[string]interface{}) + objectMap["metric"] = alst.Metric + if alst.LowerLoadThreshold != nil { + objectMap["lowerLoadThreshold"] = alst.LowerLoadThreshold + } + if alst.UpperLoadThreshold != nil { + objectMap["upperLoadThreshold"] = alst.UpperLoadThreshold + } + if alst.ScaleIntervalInSeconds != nil { + objectMap["scaleIntervalInSeconds"] = alst.ScaleIntervalInSeconds + } + if alst.Kind != "" { + objectMap["kind"] = alst.Kind + } + return json.Marshal(objectMap) +} + +// AsAverageLoadScalingTrigger is the BasicAutoScalingTrigger implementation for AverageLoadScalingTrigger. +func (alst AverageLoadScalingTrigger) AsAverageLoadScalingTrigger() (*AverageLoadScalingTrigger, bool) { + return &alst, true +} + +// AsAutoScalingTrigger is the BasicAutoScalingTrigger implementation for AverageLoadScalingTrigger. +func (alst AverageLoadScalingTrigger) AsAutoScalingTrigger() (*AutoScalingTrigger, bool) { + return nil, false +} + +// AsBasicAutoScalingTrigger is the BasicAutoScalingTrigger implementation for AverageLoadScalingTrigger. +func (alst AverageLoadScalingTrigger) AsBasicAutoScalingTrigger() (BasicAutoScalingTrigger, bool) { + return &alst, true +} + +// UnmarshalJSON is the custom unmarshaler for AverageLoadScalingTrigger struct. +func (alst *AverageLoadScalingTrigger) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "metric": + if v != nil { + metric, err := unmarshalBasicAutoScalingMetric(*v) + if err != nil { + return err + } + alst.Metric = metric + } + case "lowerLoadThreshold": + if v != nil { + var lowerLoadThreshold float64 + err = json.Unmarshal(*v, &lowerLoadThreshold) + if err != nil { + return err + } + alst.LowerLoadThreshold = &lowerLoadThreshold + } + case "upperLoadThreshold": + if v != nil { + var upperLoadThreshold float64 + err = json.Unmarshal(*v, &upperLoadThreshold) + if err != nil { + return err + } + alst.UpperLoadThreshold = &upperLoadThreshold + } + case "scaleIntervalInSeconds": + if v != nil { + var scaleIntervalInSeconds int32 + err = json.Unmarshal(*v, &scaleIntervalInSeconds) + if err != nil { + return err + } + alst.ScaleIntervalInSeconds = &scaleIntervalInSeconds + } + case "kind": + if v != nil { + var kind KindBasicAutoScalingTrigger + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + alst.Kind = kind + } + } + } + + return nil +} + +// AzureInternalMonitoringPipelineSinkDescription diagnostics settings for Geneva. +type AzureInternalMonitoringPipelineSinkDescription struct { + // AccountName - Azure Internal monitoring pipeline account. + AccountName *string `json:"accountName,omitempty"` + // Namespace - Azure Internal monitoring pipeline account namespace. + Namespace *string `json:"namespace,omitempty"` + // MaConfigURL - Azure Internal monitoring agent configuration. + MaConfigURL *string `json:"maConfigUrl,omitempty"` + // FluentdConfigURL - Azure Internal monitoring agent fluentd configuration. + FluentdConfigURL interface{} `json:"fluentdConfigUrl,omitempty"` + // AutoKeyConfigURL - Azure Internal monitoring pipeline autokey associated with the certificate. + AutoKeyConfigURL *string `json:"autoKeyConfigUrl,omitempty"` + // Name - Name of the sink. This value is referenced by DiagnosticsReferenceDescription + Name *string `json:"name,omitempty"` + // Description - A description of the sink. + Description *string `json:"description,omitempty"` + // Kind - Possible values include: 'KindDiagnosticsSinkProperties', 'KindAzureInternalMonitoringPipeline' + Kind KindBasicDiagnosticsSinkProperties `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureInternalMonitoringPipelineSinkDescription. +func (aimpsd AzureInternalMonitoringPipelineSinkDescription) MarshalJSON() ([]byte, error) { + aimpsd.Kind = KindAzureInternalMonitoringPipeline + objectMap := make(map[string]interface{}) + if aimpsd.AccountName != nil { + objectMap["accountName"] = aimpsd.AccountName + } + if aimpsd.Namespace != nil { + objectMap["namespace"] = aimpsd.Namespace + } + if aimpsd.MaConfigURL != nil { + objectMap["maConfigUrl"] = aimpsd.MaConfigURL + } + if aimpsd.FluentdConfigURL != nil { + objectMap["fluentdConfigUrl"] = aimpsd.FluentdConfigURL + } + if aimpsd.AutoKeyConfigURL != nil { + objectMap["autoKeyConfigUrl"] = aimpsd.AutoKeyConfigURL + } + if aimpsd.Name != nil { + objectMap["name"] = aimpsd.Name + } + if aimpsd.Description != nil { + objectMap["description"] = aimpsd.Description + } + if aimpsd.Kind != "" { + objectMap["kind"] = aimpsd.Kind + } + return json.Marshal(objectMap) +} + +// AsAzureInternalMonitoringPipelineSinkDescription is the BasicDiagnosticsSinkProperties implementation for AzureInternalMonitoringPipelineSinkDescription. +func (aimpsd AzureInternalMonitoringPipelineSinkDescription) AsAzureInternalMonitoringPipelineSinkDescription() (*AzureInternalMonitoringPipelineSinkDescription, bool) { + return &aimpsd, true +} + +// AsDiagnosticsSinkProperties is the BasicDiagnosticsSinkProperties implementation for AzureInternalMonitoringPipelineSinkDescription. +func (aimpsd AzureInternalMonitoringPipelineSinkDescription) AsDiagnosticsSinkProperties() (*DiagnosticsSinkProperties, bool) { + return nil, false +} + +// AsBasicDiagnosticsSinkProperties is the BasicDiagnosticsSinkProperties implementation for AzureInternalMonitoringPipelineSinkDescription. +func (aimpsd AzureInternalMonitoringPipelineSinkDescription) AsBasicDiagnosticsSinkProperties() (BasicDiagnosticsSinkProperties, bool) { + return &aimpsd, true +} + +// ContainerCodePackageProperties describes a container and its runtime properties. +type ContainerCodePackageProperties struct { + // Name - The name of the code package. + Name *string `json:"name,omitempty"` + // Image - The Container image to use. + Image *string `json:"image,omitempty"` + // ImageRegistryCredential - Image registry credential. + ImageRegistryCredential *ImageRegistryCredential `json:"imageRegistryCredential,omitempty"` + // Entrypoint - Override for the default entry point in the container. + Entrypoint *string `json:"entrypoint,omitempty"` + // Commands - Command array to execute within the container in exec form. + Commands *[]string `json:"commands,omitempty"` + // EnvironmentVariables - The environment variables to set in this container + EnvironmentVariables *[]EnvironmentVariable `json:"environmentVariables,omitempty"` + // Settings - The settings to set in this container. The setting file path can be fetched from environment variable "Fabric_SettingPath". The path for Windows container is "C:\\secrets". The path for Linux container is "/var/secrets". + Settings *[]Setting `json:"settings,omitempty"` + // Labels - The labels to set in this container. + Labels *[]ContainerLabel `json:"labels,omitempty"` + // Endpoints - The endpoints exposed by this container. + Endpoints *[]EndpointProperties `json:"endpoints,omitempty"` + // Resources - The resources required by this container. + Resources *ResourceRequirements `json:"resources,omitempty"` + // VolumeRefs - Volumes to be attached to the container. The lifetime of these volumes is independent of the application's lifetime. + VolumeRefs *[]VolumeReference `json:"volumeRefs,omitempty"` + // Volumes - Volumes to be attached to the container. The lifetime of these volumes is scoped to the application's lifetime. + Volumes *[]ApplicationScopedVolume `json:"volumes,omitempty"` + // Diagnostics - Reference to sinks in DiagnosticsDescription. + Diagnostics *DiagnosticsRef `json:"diagnostics,omitempty"` + // ReliableCollectionsRefs - A list of ReliableCollection resources used by this particular code package. Please refer to ReliableCollectionsRef for more details. + ReliableCollectionsRefs *[]ReliableCollectionsRef `json:"reliableCollectionsRefs,omitempty"` + // InstanceView - READ-ONLY; Runtime information of a container instance. + InstanceView *ContainerInstanceView `json:"instanceView,omitempty"` +} + +// ContainerEvent a container event. +type ContainerEvent struct { + // Name - The name of the container event. + Name *string `json:"name,omitempty"` + // Count - The count of the event. + Count *int32 `json:"count,omitempty"` + // FirstTimestamp - Date/time of the first event. + FirstTimestamp *string `json:"firstTimestamp,omitempty"` + // LastTimestamp - Date/time of the last event. + LastTimestamp *string `json:"lastTimestamp,omitempty"` + // Message - The event message + Message *string `json:"message,omitempty"` + // Type - The event type. + Type *string `json:"type,omitempty"` +} + +// ContainerInstanceView runtime information of a container instance. +type ContainerInstanceView struct { + // RestartCount - The number of times the container has been restarted. + RestartCount *int32 `json:"restartCount,omitempty"` + // CurrentState - Current container instance state. + CurrentState *ContainerState `json:"currentState,omitempty"` + // PreviousState - Previous container instance state. + PreviousState *ContainerState `json:"previousState,omitempty"` + // Events - The events of this container instance. + Events *[]ContainerEvent `json:"events,omitempty"` +} + +// ContainerLabel describes a container label. +type ContainerLabel struct { + // Name - The name of the container label. + Name *string `json:"name,omitempty"` + // Value - The value of the container label. + Value *string `json:"value,omitempty"` +} + +// ContainerLogs container logs. +type ContainerLogs struct { + autorest.Response `json:"-"` + // Content - Container logs. + Content *string `json:"content,omitempty"` +} + +// ContainerState the container state. +type ContainerState struct { + // State - The state of this container + State *string `json:"state,omitempty"` + // StartTime - Date/time when the container state started. + StartTime *date.Time `json:"startTime,omitempty"` + // ExitCode - The container exit code. + ExitCode *string `json:"exitCode,omitempty"` + // FinishTime - Date/time when the container state finished. + FinishTime *date.Time `json:"finishTime,omitempty"` + // DetailStatus - Human-readable status of this state. + DetailStatus *string `json:"detailStatus,omitempty"` +} + +// DiagnosticsDescription describes the diagnostics options available +type DiagnosticsDescription struct { + // Sinks - List of supported sinks that can be referenced. + Sinks *[]BasicDiagnosticsSinkProperties `json:"sinks,omitempty"` + // Enabled - Status of whether or not sinks are enabled. + Enabled *bool `json:"enabled,omitempty"` + // DefaultSinkRefs - The sinks to be used if diagnostics is enabled. Sink choices can be overridden at the service and code package level. + DefaultSinkRefs *[]string `json:"defaultSinkRefs,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for DiagnosticsDescription struct. +func (dd *DiagnosticsDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sinks": + if v != nil { + sinks, err := unmarshalBasicDiagnosticsSinkPropertiesArray(*v) + if err != nil { + return err + } + dd.Sinks = &sinks + } + case "enabled": + if v != nil { + var enabled bool + err = json.Unmarshal(*v, &enabled) + if err != nil { + return err + } + dd.Enabled = &enabled + } + case "defaultSinkRefs": + if v != nil { + var defaultSinkRefs []string + err = json.Unmarshal(*v, &defaultSinkRefs) + if err != nil { + return err + } + dd.DefaultSinkRefs = &defaultSinkRefs + } + } + } + + return nil +} + +// DiagnosticsRef reference to sinks in DiagnosticsDescription. +type DiagnosticsRef struct { + // Enabled - Status of whether or not sinks are enabled. + Enabled *bool `json:"enabled,omitempty"` + // SinkRefs - List of sinks to be used if enabled. References the list of sinks in DiagnosticsDescription. + SinkRefs *[]string `json:"sinkRefs,omitempty"` +} + +// BasicDiagnosticsSinkProperties properties of a DiagnosticsSink. +type BasicDiagnosticsSinkProperties interface { + AsAzureInternalMonitoringPipelineSinkDescription() (*AzureInternalMonitoringPipelineSinkDescription, bool) + AsDiagnosticsSinkProperties() (*DiagnosticsSinkProperties, bool) +} + +// DiagnosticsSinkProperties properties of a DiagnosticsSink. +type DiagnosticsSinkProperties struct { + // Name - Name of the sink. This value is referenced by DiagnosticsReferenceDescription + Name *string `json:"name,omitempty"` + // Description - A description of the sink. + Description *string `json:"description,omitempty"` + // Kind - Possible values include: 'KindDiagnosticsSinkProperties', 'KindAzureInternalMonitoringPipeline' + Kind KindBasicDiagnosticsSinkProperties `json:"kind,omitempty"` +} + +func unmarshalBasicDiagnosticsSinkProperties(body []byte) (BasicDiagnosticsSinkProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindAzureInternalMonitoringPipeline): + var aimpsd AzureInternalMonitoringPipelineSinkDescription + err := json.Unmarshal(body, &aimpsd) + return aimpsd, err + default: + var dsp DiagnosticsSinkProperties + err := json.Unmarshal(body, &dsp) + return dsp, err + } +} +func unmarshalBasicDiagnosticsSinkPropertiesArray(body []byte) ([]BasicDiagnosticsSinkProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + dspArray := make([]BasicDiagnosticsSinkProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + dsp, err := unmarshalBasicDiagnosticsSinkProperties(*rawMessage) + if err != nil { + return nil, err + } + dspArray[index] = dsp + } + return dspArray, nil +} + +// MarshalJSON is the custom marshaler for DiagnosticsSinkProperties. +func (dsp DiagnosticsSinkProperties) MarshalJSON() ([]byte, error) { + dsp.Kind = KindDiagnosticsSinkProperties + objectMap := make(map[string]interface{}) + if dsp.Name != nil { + objectMap["name"] = dsp.Name + } + if dsp.Description != nil { + objectMap["description"] = dsp.Description + } + if dsp.Kind != "" { + objectMap["kind"] = dsp.Kind + } + return json.Marshal(objectMap) +} + +// AsAzureInternalMonitoringPipelineSinkDescription is the BasicDiagnosticsSinkProperties implementation for DiagnosticsSinkProperties. +func (dsp DiagnosticsSinkProperties) AsAzureInternalMonitoringPipelineSinkDescription() (*AzureInternalMonitoringPipelineSinkDescription, bool) { + return nil, false +} + +// AsDiagnosticsSinkProperties is the BasicDiagnosticsSinkProperties implementation for DiagnosticsSinkProperties. +func (dsp DiagnosticsSinkProperties) AsDiagnosticsSinkProperties() (*DiagnosticsSinkProperties, bool) { + return &dsp, true +} + +// AsBasicDiagnosticsSinkProperties is the BasicDiagnosticsSinkProperties implementation for DiagnosticsSinkProperties. +func (dsp DiagnosticsSinkProperties) AsBasicDiagnosticsSinkProperties() (BasicDiagnosticsSinkProperties, bool) { + return &dsp, true +} + +// EndpointProperties describes a container endpoint. +type EndpointProperties struct { + // Name - The name of the endpoint. + Name *string `json:"name,omitempty"` + // Port - Port used by the container. + Port *int32 `json:"port,omitempty"` +} + +// EndpointRef describes a reference to a service endpoint. +type EndpointRef struct { + // Name - Name of the endpoint. + Name *string `json:"name,omitempty"` +} + +// EnvironmentVariable describes an environment variable for the container. +type EnvironmentVariable struct { + // Name - The name of the environment variable. + Name *string `json:"name,omitempty"` + // Value - The value of the environment variable. + Value *string `json:"value,omitempty"` +} + +// ErrorDetailsModel error model details information +type ErrorDetailsModel struct { + Code *string `json:"code,omitempty"` + // Message - Error message. + Message *string `json:"message,omitempty"` +} + +// ErrorErrorModel error model information +type ErrorErrorModel struct { + Code *string `json:"code,omitempty"` + // Message - Error message. + Message *string `json:"message,omitempty"` + InnerError *string `json:"innerError,omitempty"` + // Details - List of error message details. + Details *[]ErrorDetailsModel `json:"details,omitempty"` +} + +// ErrorModel the error details. +type ErrorModel struct { + // Error - Error model information + Error *ErrorErrorModel `json:"error,omitempty"` +} + +// GatewayDestination describes destination endpoint for routing traffic. +type GatewayDestination struct { + // ApplicationName - Name of the service fabric Mesh application. + ApplicationName *string `json:"applicationName,omitempty"` + // ServiceName - service that contains the endpoint. + ServiceName *string `json:"serviceName,omitempty"` + // EndpointName - name of the endpoint in the service. + EndpointName *string `json:"endpointName,omitempty"` +} + +// GatewayProperties describes properties of a gateway resource. +type GatewayProperties struct { + // Description - User readable description of the gateway. + Description *string `json:"description,omitempty"` + // SourceNetwork - Network the gateway should listen on for requests. + SourceNetwork *NetworkRef `json:"sourceNetwork,omitempty"` + // DestinationNetwork - Network that the Application is using. + DestinationNetwork *NetworkRef `json:"destinationNetwork,omitempty"` + // TCP - Configuration for tcp connectivity for this gateway. + TCP *[]TCPConfig `json:"tcp,omitempty"` + // HTTP - Configuration for http connectivity for this gateway. + HTTP *[]HTTPConfig `json:"http,omitempty"` + // Status - READ-ONLY; Status of the resource. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the gateway. + StatusDetails *string `json:"statusDetails,omitempty"` + // IPAddress - READ-ONLY; IP address of the gateway. This is populated in the response and is ignored for incoming requests. + IPAddress *string `json:"ipAddress,omitempty"` +} + +// GatewayResourceDescription this type describes a gateway resource. +type GatewayResourceDescription struct { + autorest.Response `json:"-"` + // GatewayResourceProperties - This type describes properties of a gateway resource. + *GatewayResourceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for GatewayResourceDescription. +func (grd GatewayResourceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if grd.GatewayResourceProperties != nil { + objectMap["properties"] = grd.GatewayResourceProperties + } + if grd.Tags != nil { + objectMap["tags"] = grd.Tags + } + if grd.Location != nil { + objectMap["location"] = grd.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GatewayResourceDescription struct. +func (grd *GatewayResourceDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var gatewayResourceProperties GatewayResourceProperties + err = json.Unmarshal(*v, &gatewayResourceProperties) + if err != nil { + return err + } + grd.GatewayResourceProperties = &gatewayResourceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + grd.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + grd.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + grd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + grd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + grd.Type = &typeVar + } + } + } + + return nil +} + +// GatewayResourceDescriptionList a pageable list of gateway resources. +type GatewayResourceDescriptionList struct { + autorest.Response `json:"-"` + // Value - One page of the list. + Value *[]GatewayResourceDescription `json:"value,omitempty"` + // NextLink - URI to fetch the next page of the list. + NextLink *string `json:"nextLink,omitempty"` +} + +// GatewayResourceDescriptionListIterator provides access to a complete listing of +// GatewayResourceDescription values. +type GatewayResourceDescriptionListIterator struct { + i int + page GatewayResourceDescriptionListPage +} + +// NextWithContext 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 *GatewayResourceDescriptionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayResourceDescriptionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *GatewayResourceDescriptionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter GatewayResourceDescriptionListIterator) 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 GatewayResourceDescriptionListIterator) Response() GatewayResourceDescriptionList { + 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 GatewayResourceDescriptionListIterator) Value() GatewayResourceDescription { + if !iter.page.NotDone() { + return GatewayResourceDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the GatewayResourceDescriptionListIterator type. +func NewGatewayResourceDescriptionListIterator(page GatewayResourceDescriptionListPage) GatewayResourceDescriptionListIterator { + return GatewayResourceDescriptionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (grdl GatewayResourceDescriptionList) IsEmpty() bool { + return grdl.Value == nil || len(*grdl.Value) == 0 +} + +// gatewayResourceDescriptionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (grdl GatewayResourceDescriptionList) gatewayResourceDescriptionListPreparer(ctx context.Context) (*http.Request, error) { + if grdl.NextLink == nil || len(to.String(grdl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(grdl.NextLink))) +} + +// GatewayResourceDescriptionListPage contains a page of GatewayResourceDescription values. +type GatewayResourceDescriptionListPage struct { + fn func(context.Context, GatewayResourceDescriptionList) (GatewayResourceDescriptionList, error) + grdl GatewayResourceDescriptionList +} + +// NextWithContext 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 *GatewayResourceDescriptionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GatewayResourceDescriptionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.grdl) + if err != nil { + return err + } + page.grdl = next + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *GatewayResourceDescriptionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page GatewayResourceDescriptionListPage) NotDone() bool { + return !page.grdl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page GatewayResourceDescriptionListPage) Response() GatewayResourceDescriptionList { + return page.grdl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page GatewayResourceDescriptionListPage) Values() []GatewayResourceDescription { + if page.grdl.IsEmpty() { + return nil + } + return *page.grdl.Value +} + +// Creates a new instance of the GatewayResourceDescriptionListPage type. +func NewGatewayResourceDescriptionListPage(getNextPage func(context.Context, GatewayResourceDescriptionList) (GatewayResourceDescriptionList, error)) GatewayResourceDescriptionListPage { + return GatewayResourceDescriptionListPage{fn: getNextPage} +} + +// GatewayResourceProperties this type describes properties of a gateway resource. +type GatewayResourceProperties struct { + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Description - User readable description of the gateway. + Description *string `json:"description,omitempty"` + // SourceNetwork - Network the gateway should listen on for requests. + SourceNetwork *NetworkRef `json:"sourceNetwork,omitempty"` + // DestinationNetwork - Network that the Application is using. + DestinationNetwork *NetworkRef `json:"destinationNetwork,omitempty"` + // TCP - Configuration for tcp connectivity for this gateway. + TCP *[]TCPConfig `json:"tcp,omitempty"` + // HTTP - Configuration for http connectivity for this gateway. + HTTP *[]HTTPConfig `json:"http,omitempty"` + // Status - READ-ONLY; Status of the resource. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the gateway. + StatusDetails *string `json:"statusDetails,omitempty"` + // IPAddress - READ-ONLY; IP address of the gateway. This is populated in the response and is ignored for incoming requests. + IPAddress *string `json:"ipAddress,omitempty"` +} + +// HTTPConfig describes the http configuration for external connectivity for this network. +type HTTPConfig struct { + // Name - http gateway config name. + Name *string `json:"name,omitempty"` + // Port - Specifies the port at which the service endpoint below needs to be exposed. + Port *int32 `json:"port,omitempty"` + // Hosts - description for routing. + Hosts *[]HTTPHostConfig `json:"hosts,omitempty"` +} + +// HTTPHostConfig describes the hostname properties for http routing. +type HTTPHostConfig struct { + // Name - http hostname config name. + Name *string `json:"name,omitempty"` + // Routes - Route information to use for routing. Routes are processed in the order they are specified. Specify routes that are more specific before routes that can handle general cases. + Routes *[]HTTPRouteConfig `json:"routes,omitempty"` +} + +// HTTPRouteConfig describes the hostname properties for http routing. +type HTTPRouteConfig struct { + // Name - http route name. + Name *string `json:"name,omitempty"` + // Match - Describes a rule for http route matching. + Match *HTTPRouteMatchRule `json:"match,omitempty"` + // Destination - Describes destination endpoint for routing traffic. + Destination *GatewayDestination `json:"destination,omitempty"` +} + +// HTTPRouteMatchHeader describes header information for http route matching. +type HTTPRouteMatchHeader struct { + // Name - Name of header to match in request. + Name *string `json:"name,omitempty"` + // Value - Value of header to match in request. + Value *string `json:"value,omitempty"` + // Type - how to match header value. Possible values include: 'Exact' + Type HeaderMatchType `json:"type,omitempty"` +} + +// HTTPRouteMatchPath path to match for routing. +type HTTPRouteMatchPath struct { + // Value - Uri path to match for request. + Value *string `json:"value,omitempty"` + // Rewrite - replacement string for matched part of the Uri. + Rewrite *string `json:"rewrite,omitempty"` + // Type - how to match value in the Uri + Type *string `json:"type,omitempty"` +} + +// HTTPRouteMatchRule describes a rule for http route matching. +type HTTPRouteMatchRule struct { + // Path - Path to match for routing. + Path *HTTPRouteMatchPath `json:"path,omitempty"` + // Headers - headers and their values to match in request. + Headers *[]HTTPRouteMatchHeader `json:"headers,omitempty"` +} + +// ImageRegistryCredential image registry credential. +type ImageRegistryCredential struct { + // Server - Docker image registry server, without protocol such as `http` and `https`. + Server *string `json:"server,omitempty"` + // Username - The username for the private registry. + Username *string `json:"username,omitempty"` + // Password - The password for the private registry. The password is required for create or update operations, however it is not returned in the get or list operations. + Password *string `json:"password,omitempty"` +} + +// InlinedValueSecretResourceProperties describes the properties of a secret resource whose value is +// provided explicitly as plaintext. The secret resource may have multiple values, each being uniquely +// versioned. The secret value of each version is stored encrypted, and delivered as plaintext into the +// context of applications referencing it. +type InlinedValueSecretResourceProperties struct { + // Description - User readable description of the secret. + Description *string `json:"description,omitempty"` + // Status - READ-ONLY; Status of the resource. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the secret. + StatusDetails *string `json:"statusDetails,omitempty"` + // ContentType - The type of the content stored in the secret value. The value of this property is opaque to Service Fabric. Once set, the value of this property cannot be changed. + ContentType *string `json:"contentType,omitempty"` + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Kind - Possible values include: 'KindSecretResourcePropertiesBase', 'KindSecretResourceProperties', 'KindInlinedValue' + Kind Kind `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for InlinedValueSecretResourceProperties. +func (ivsrp InlinedValueSecretResourceProperties) MarshalJSON() ([]byte, error) { + ivsrp.Kind = KindInlinedValue + objectMap := make(map[string]interface{}) + if ivsrp.Description != nil { + objectMap["description"] = ivsrp.Description + } + if ivsrp.ContentType != nil { + objectMap["contentType"] = ivsrp.ContentType + } + if ivsrp.Kind != "" { + objectMap["kind"] = ivsrp.Kind + } + return json.Marshal(objectMap) +} + +// AsSecretResourceProperties is the BasicSecretResourcePropertiesBase implementation for InlinedValueSecretResourceProperties. +func (ivsrp InlinedValueSecretResourceProperties) AsSecretResourceProperties() (*SecretResourceProperties, bool) { + return nil, false +} + +// AsBasicSecretResourceProperties is the BasicSecretResourcePropertiesBase implementation for InlinedValueSecretResourceProperties. +func (ivsrp InlinedValueSecretResourceProperties) AsBasicSecretResourceProperties() (BasicSecretResourceProperties, bool) { + return &ivsrp, true +} + +// AsInlinedValueSecretResourceProperties is the BasicSecretResourcePropertiesBase implementation for InlinedValueSecretResourceProperties. +func (ivsrp InlinedValueSecretResourceProperties) AsInlinedValueSecretResourceProperties() (*InlinedValueSecretResourceProperties, bool) { + return &ivsrp, true +} + +// AsSecretResourcePropertiesBase is the BasicSecretResourcePropertiesBase implementation for InlinedValueSecretResourceProperties. +func (ivsrp InlinedValueSecretResourceProperties) AsSecretResourcePropertiesBase() (*SecretResourcePropertiesBase, bool) { + return nil, false +} + +// AsBasicSecretResourcePropertiesBase is the BasicSecretResourcePropertiesBase implementation for InlinedValueSecretResourceProperties. +func (ivsrp InlinedValueSecretResourceProperties) AsBasicSecretResourcePropertiesBase() (BasicSecretResourcePropertiesBase, bool) { + return &ivsrp, true +} + +// LocalNetworkResourceProperties information about a Service Fabric container network local to a single +// Service Fabric cluster. +type LocalNetworkResourceProperties struct { + // NetworkAddressPrefix - Address space for the local container network. + NetworkAddressPrefix *string `json:"networkAddressPrefix,omitempty"` + // Description - User readable description of the network. + Description *string `json:"description,omitempty"` + // Status - READ-ONLY; Status of the network. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the network. + StatusDetails *string `json:"statusDetails,omitempty"` + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Kind - Possible values include: 'KindNetworkResourcePropertiesBase', 'KindNetworkResourceProperties', 'KindLocal' + Kind KindBasicNetworkResourcePropertiesBase `json:"kind,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocalNetworkResourceProperties. +func (lnrp LocalNetworkResourceProperties) MarshalJSON() ([]byte, error) { + lnrp.Kind = KindLocal + objectMap := make(map[string]interface{}) + if lnrp.NetworkAddressPrefix != nil { + objectMap["networkAddressPrefix"] = lnrp.NetworkAddressPrefix + } + if lnrp.Description != nil { + objectMap["description"] = lnrp.Description + } + if lnrp.Kind != "" { + objectMap["kind"] = lnrp.Kind + } + return json.Marshal(objectMap) +} + +// AsNetworkResourceProperties is the BasicNetworkResourcePropertiesBase implementation for LocalNetworkResourceProperties. +func (lnrp LocalNetworkResourceProperties) AsNetworkResourceProperties() (*NetworkResourceProperties, bool) { + return nil, false +} + +// AsBasicNetworkResourceProperties is the BasicNetworkResourcePropertiesBase implementation for LocalNetworkResourceProperties. +func (lnrp LocalNetworkResourceProperties) AsBasicNetworkResourceProperties() (BasicNetworkResourceProperties, bool) { + return &lnrp, true +} + +// AsLocalNetworkResourceProperties is the BasicNetworkResourcePropertiesBase implementation for LocalNetworkResourceProperties. +func (lnrp LocalNetworkResourceProperties) AsLocalNetworkResourceProperties() (*LocalNetworkResourceProperties, bool) { + return &lnrp, true +} + +// AsNetworkResourcePropertiesBase is the BasicNetworkResourcePropertiesBase implementation for LocalNetworkResourceProperties. +func (lnrp LocalNetworkResourceProperties) AsNetworkResourcePropertiesBase() (*NetworkResourcePropertiesBase, bool) { + return nil, false +} + +// AsBasicNetworkResourcePropertiesBase is the BasicNetworkResourcePropertiesBase implementation for LocalNetworkResourceProperties. +func (lnrp LocalNetworkResourceProperties) AsBasicNetworkResourcePropertiesBase() (BasicNetworkResourcePropertiesBase, bool) { + return &lnrp, true +} + +// ManagedProxyResource the resource model definition for Azure Resource Manager proxy resource. It will +// have everything other than required location and tags. This proxy resource is explicitly created or +// updated by including it in the parent resource. +type ManagedProxyResource struct { + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// NetworkRef describes a network reference in a service. +type NetworkRef struct { + // Name - Name of the network + Name *string `json:"name,omitempty"` + // EndpointRefs - A list of endpoints that are exposed on this network. + EndpointRefs *[]EndpointRef `json:"endpointRefs,omitempty"` +} + +// NetworkResourceDescription this type describes a network resource. +type NetworkResourceDescription struct { + autorest.Response `json:"-"` + // Properties - Describes properties of a network resource. + Properties BasicNetworkResourceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for NetworkResourceDescription. +func (nrd NetworkResourceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["properties"] = nrd.Properties + if nrd.Tags != nil { + objectMap["tags"] = nrd.Tags + } + if nrd.Location != nil { + objectMap["location"] = nrd.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for NetworkResourceDescription struct. +func (nrd *NetworkResourceDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + properties, err := unmarshalBasicNetworkResourceProperties(*v) + if err != nil { + return err + } + nrd.Properties = properties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + nrd.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + nrd.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + nrd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + nrd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + nrd.Type = &typeVar + } + } + } + + return nil +} + +// NetworkResourceDescriptionList a pageable list of network resources. +type NetworkResourceDescriptionList struct { + autorest.Response `json:"-"` + // Value - One page of the list. + Value *[]NetworkResourceDescription `json:"value,omitempty"` + // NextLink - URI to fetch the next page of the list. + NextLink *string `json:"nextLink,omitempty"` +} + +// NetworkResourceDescriptionListIterator provides access to a complete listing of +// NetworkResourceDescription values. +type NetworkResourceDescriptionListIterator struct { + i int + page NetworkResourceDescriptionListPage +} + +// NextWithContext 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 *NetworkResourceDescriptionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkResourceDescriptionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *NetworkResourceDescriptionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter NetworkResourceDescriptionListIterator) 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 NetworkResourceDescriptionListIterator) Response() NetworkResourceDescriptionList { + 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 NetworkResourceDescriptionListIterator) Value() NetworkResourceDescription { + if !iter.page.NotDone() { + return NetworkResourceDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the NetworkResourceDescriptionListIterator type. +func NewNetworkResourceDescriptionListIterator(page NetworkResourceDescriptionListPage) NetworkResourceDescriptionListIterator { + return NetworkResourceDescriptionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (nrdl NetworkResourceDescriptionList) IsEmpty() bool { + return nrdl.Value == nil || len(*nrdl.Value) == 0 +} + +// networkResourceDescriptionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (nrdl NetworkResourceDescriptionList) networkResourceDescriptionListPreparer(ctx context.Context) (*http.Request, error) { + if nrdl.NextLink == nil || len(to.String(nrdl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(nrdl.NextLink))) +} + +// NetworkResourceDescriptionListPage contains a page of NetworkResourceDescription values. +type NetworkResourceDescriptionListPage struct { + fn func(context.Context, NetworkResourceDescriptionList) (NetworkResourceDescriptionList, error) + nrdl NetworkResourceDescriptionList +} + +// NextWithContext 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 *NetworkResourceDescriptionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkResourceDescriptionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.nrdl) + if err != nil { + return err + } + page.nrdl = next + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *NetworkResourceDescriptionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page NetworkResourceDescriptionListPage) NotDone() bool { + return !page.nrdl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page NetworkResourceDescriptionListPage) Response() NetworkResourceDescriptionList { + return page.nrdl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page NetworkResourceDescriptionListPage) Values() []NetworkResourceDescription { + if page.nrdl.IsEmpty() { + return nil + } + return *page.nrdl.Value +} + +// Creates a new instance of the NetworkResourceDescriptionListPage type. +func NewNetworkResourceDescriptionListPage(getNextPage func(context.Context, NetworkResourceDescriptionList) (NetworkResourceDescriptionList, error)) NetworkResourceDescriptionListPage { + return NetworkResourceDescriptionListPage{fn: getNextPage} +} + +// BasicNetworkResourceProperties describes properties of a network resource. +type BasicNetworkResourceProperties interface { + AsLocalNetworkResourceProperties() (*LocalNetworkResourceProperties, bool) + AsNetworkResourceProperties() (*NetworkResourceProperties, bool) +} + +// NetworkResourceProperties describes properties of a network resource. +type NetworkResourceProperties struct { + // Description - User readable description of the network. + Description *string `json:"description,omitempty"` + // Status - READ-ONLY; Status of the network. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the network. + StatusDetails *string `json:"statusDetails,omitempty"` + // Kind - Possible values include: 'KindNetworkResourcePropertiesBase', 'KindNetworkResourceProperties', 'KindLocal' + Kind KindBasicNetworkResourcePropertiesBase `json:"kind,omitempty"` + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +func unmarshalBasicNetworkResourceProperties(body []byte) (BasicNetworkResourceProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindLocal): + var lnrp LocalNetworkResourceProperties + err := json.Unmarshal(body, &lnrp) + return lnrp, err + default: + var nrp NetworkResourceProperties + err := json.Unmarshal(body, &nrp) + return nrp, err + } +} +func unmarshalBasicNetworkResourcePropertiesArray(body []byte) ([]BasicNetworkResourceProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + nrpArray := make([]BasicNetworkResourceProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + nrp, err := unmarshalBasicNetworkResourceProperties(*rawMessage) + if err != nil { + return nil, err + } + nrpArray[index] = nrp + } + return nrpArray, nil +} + +// MarshalJSON is the custom marshaler for NetworkResourceProperties. +func (nrp NetworkResourceProperties) MarshalJSON() ([]byte, error) { + nrp.Kind = KindNetworkResourceProperties + objectMap := make(map[string]interface{}) + if nrp.Description != nil { + objectMap["description"] = nrp.Description + } + if nrp.Kind != "" { + objectMap["kind"] = nrp.Kind + } + return json.Marshal(objectMap) +} + +// AsNetworkResourceProperties is the BasicNetworkResourcePropertiesBase implementation for NetworkResourceProperties. +func (nrp NetworkResourceProperties) AsNetworkResourceProperties() (*NetworkResourceProperties, bool) { + return &nrp, true +} + +// AsBasicNetworkResourceProperties is the BasicNetworkResourcePropertiesBase implementation for NetworkResourceProperties. +func (nrp NetworkResourceProperties) AsBasicNetworkResourceProperties() (BasicNetworkResourceProperties, bool) { + return &nrp, true +} + +// AsLocalNetworkResourceProperties is the BasicNetworkResourcePropertiesBase implementation for NetworkResourceProperties. +func (nrp NetworkResourceProperties) AsLocalNetworkResourceProperties() (*LocalNetworkResourceProperties, bool) { + return nil, false +} + +// AsNetworkResourcePropertiesBase is the BasicNetworkResourcePropertiesBase implementation for NetworkResourceProperties. +func (nrp NetworkResourceProperties) AsNetworkResourcePropertiesBase() (*NetworkResourcePropertiesBase, bool) { + return nil, false +} + +// AsBasicNetworkResourcePropertiesBase is the BasicNetworkResourcePropertiesBase implementation for NetworkResourceProperties. +func (nrp NetworkResourceProperties) AsBasicNetworkResourcePropertiesBase() (BasicNetworkResourcePropertiesBase, bool) { + return &nrp, true +} + +// BasicNetworkResourcePropertiesBase this type describes the properties of a network resource, including its kind. +type BasicNetworkResourcePropertiesBase interface { + AsNetworkResourceProperties() (*NetworkResourceProperties, bool) + AsBasicNetworkResourceProperties() (BasicNetworkResourceProperties, bool) + AsLocalNetworkResourceProperties() (*LocalNetworkResourceProperties, bool) + AsNetworkResourcePropertiesBase() (*NetworkResourcePropertiesBase, bool) +} + +// NetworkResourcePropertiesBase this type describes the properties of a network resource, including its kind. +type NetworkResourcePropertiesBase struct { + // Kind - Possible values include: 'KindNetworkResourcePropertiesBase', 'KindNetworkResourceProperties', 'KindLocal' + Kind KindBasicNetworkResourcePropertiesBase `json:"kind,omitempty"` + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +func unmarshalBasicNetworkResourcePropertiesBase(body []byte) (BasicNetworkResourcePropertiesBase, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindNetworkResourceProperties): + var nrp NetworkResourceProperties + err := json.Unmarshal(body, &nrp) + return nrp, err + case string(KindLocal): + var lnrp LocalNetworkResourceProperties + err := json.Unmarshal(body, &lnrp) + return lnrp, err + default: + var nrpb NetworkResourcePropertiesBase + err := json.Unmarshal(body, &nrpb) + return nrpb, err + } +} +func unmarshalBasicNetworkResourcePropertiesBaseArray(body []byte) ([]BasicNetworkResourcePropertiesBase, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + nrpbArray := make([]BasicNetworkResourcePropertiesBase, len(rawMessages)) + + for index, rawMessage := range rawMessages { + nrpb, err := unmarshalBasicNetworkResourcePropertiesBase(*rawMessage) + if err != nil { + return nil, err + } + nrpbArray[index] = nrpb + } + return nrpbArray, nil +} + +// MarshalJSON is the custom marshaler for NetworkResourcePropertiesBase. +func (nrpb NetworkResourcePropertiesBase) MarshalJSON() ([]byte, error) { + nrpb.Kind = KindNetworkResourcePropertiesBase + objectMap := make(map[string]interface{}) + if nrpb.Kind != "" { + objectMap["kind"] = nrpb.Kind + } + return json.Marshal(objectMap) +} + +// AsNetworkResourceProperties is the BasicNetworkResourcePropertiesBase implementation for NetworkResourcePropertiesBase. +func (nrpb NetworkResourcePropertiesBase) AsNetworkResourceProperties() (*NetworkResourceProperties, bool) { + return nil, false +} + +// AsBasicNetworkResourceProperties is the BasicNetworkResourcePropertiesBase implementation for NetworkResourcePropertiesBase. +func (nrpb NetworkResourcePropertiesBase) AsBasicNetworkResourceProperties() (BasicNetworkResourceProperties, bool) { + return nil, false +} + +// AsLocalNetworkResourceProperties is the BasicNetworkResourcePropertiesBase implementation for NetworkResourcePropertiesBase. +func (nrpb NetworkResourcePropertiesBase) AsLocalNetworkResourceProperties() (*LocalNetworkResourceProperties, bool) { + return nil, false +} + +// AsNetworkResourcePropertiesBase is the BasicNetworkResourcePropertiesBase implementation for NetworkResourcePropertiesBase. +func (nrpb NetworkResourcePropertiesBase) AsNetworkResourcePropertiesBase() (*NetworkResourcePropertiesBase, bool) { + return &nrpb, true +} + +// AsBasicNetworkResourcePropertiesBase is the BasicNetworkResourcePropertiesBase implementation for NetworkResourcePropertiesBase. +func (nrpb NetworkResourcePropertiesBase) AsBasicNetworkResourcePropertiesBase() (BasicNetworkResourcePropertiesBase, bool) { + return &nrpb, true +} + +// OperationListResult describes the result of the request to list Service Fabric operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of Service Fabric operations supported by the Microsoft.ServiceFabric resource provider. + Value *[]OperationResult `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of OperationResult values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext 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 *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { + 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 OperationListResultIterator) Value() OperationResult { + if !iter.page.NotDone() { + return OperationResult{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of OperationResult values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext 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 *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []OperationResult { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} +} + +// OperationResult list of operations available at the listed Azure resource provider. +type OperationResult struct { + // Name - The name of the operation. + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *AvailableOperationDisplay `json:"display,omitempty"` + // Origin - Origin result + Origin *string `json:"origin,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ProvisionedResourceProperties describes common properties of a provisioned resource. +type ProvisionedResourceProperties struct { + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// ProxyResource the resource model definition for Azure Resource Manager proxy resource. It will have +// everything other than required location and tags. +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// ReliableCollectionsRef specifying this parameter adds support for reliable collections +type ReliableCollectionsRef struct { + // Name - Name of ReliableCollection resource. Right now it's not used and you can use any string. + Name *string `json:"name,omitempty"` + // DoNotPersistState - False (the default) if ReliableCollections state is persisted to disk as usual. True if you do not want to persist state, in which case replication is still enabled and you can use ReliableCollections as distributed cache. + DoNotPersistState *bool `json:"doNotPersistState,omitempty"` +} + +// Resource the resource model definition for Azure Resource Manager resource. +type Resource struct { + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// ResourceLimits this type describes the resource limits for a given container. It describes the most +// amount of resources a container is allowed to use before being restarted. +type ResourceLimits struct { + // MemoryInGB - The memory limit in GB. + MemoryInGB *float64 `json:"memoryInGB,omitempty"` + // CPU - CPU limits in cores. At present, only full cores are supported. + CPU *float64 `json:"cpu,omitempty"` +} + +// ResourceRequests this type describes the requested resources for a given container. It describes the +// least amount of resources required for the container. A container can consume more than requested +// resources up to the specified limits before being restarted. Currently, the requested resources are +// treated as limits. +type ResourceRequests struct { + // MemoryInGB - The memory request in GB for this container. + MemoryInGB *float64 `json:"memoryInGB,omitempty"` + // CPU - Requested number of CPU cores. At present, only full cores are supported. + CPU *float64 `json:"cpu,omitempty"` +} + +// ResourceRequirements this type describes the resource requirements for a container or a service. +type ResourceRequirements struct { + // Requests - Describes the requested resources for a given container. + Requests *ResourceRequests `json:"requests,omitempty"` + // Limits - Describes the maximum limits on the resources for a given container. + Limits *ResourceLimits `json:"limits,omitempty"` +} + +// SecretResourceDescription this type describes a secret resource. +type SecretResourceDescription struct { + autorest.Response `json:"-"` + // Properties - Describes the properties of a secret resource. + Properties BasicSecretResourceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecretResourceDescription. +func (srd SecretResourceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["properties"] = srd.Properties + if srd.Tags != nil { + objectMap["tags"] = srd.Tags + } + if srd.Location != nil { + objectMap["location"] = srd.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SecretResourceDescription struct. +func (srd *SecretResourceDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + properties, err := unmarshalBasicSecretResourceProperties(*v) + if err != nil { + return err + } + srd.Properties = properties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + srd.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + srd.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + srd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + srd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + srd.Type = &typeVar + } + } + } + + return nil +} + +// SecretResourceDescriptionList a pageable list of secret resources. +type SecretResourceDescriptionList struct { + autorest.Response `json:"-"` + // Value - One page of the list. + Value *[]SecretResourceDescription `json:"value,omitempty"` + // NextLink - URI to fetch the next page of the list. + NextLink *string `json:"nextLink,omitempty"` +} + +// SecretResourceDescriptionListIterator provides access to a complete listing of SecretResourceDescription +// values. +type SecretResourceDescriptionListIterator struct { + i int + page SecretResourceDescriptionListPage +} + +// NextWithContext 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 *SecretResourceDescriptionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretResourceDescriptionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SecretResourceDescriptionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SecretResourceDescriptionListIterator) 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 SecretResourceDescriptionListIterator) Response() SecretResourceDescriptionList { + 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 SecretResourceDescriptionListIterator) Value() SecretResourceDescription { + if !iter.page.NotDone() { + return SecretResourceDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SecretResourceDescriptionListIterator type. +func NewSecretResourceDescriptionListIterator(page SecretResourceDescriptionListPage) SecretResourceDescriptionListIterator { + return SecretResourceDescriptionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (srdl SecretResourceDescriptionList) IsEmpty() bool { + return srdl.Value == nil || len(*srdl.Value) == 0 +} + +// secretResourceDescriptionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (srdl SecretResourceDescriptionList) secretResourceDescriptionListPreparer(ctx context.Context) (*http.Request, error) { + if srdl.NextLink == nil || len(to.String(srdl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(srdl.NextLink))) +} + +// SecretResourceDescriptionListPage contains a page of SecretResourceDescription values. +type SecretResourceDescriptionListPage struct { + fn func(context.Context, SecretResourceDescriptionList) (SecretResourceDescriptionList, error) + srdl SecretResourceDescriptionList +} + +// NextWithContext 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 *SecretResourceDescriptionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretResourceDescriptionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.srdl) + if err != nil { + return err + } + page.srdl = next + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SecretResourceDescriptionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SecretResourceDescriptionListPage) NotDone() bool { + return !page.srdl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SecretResourceDescriptionListPage) Response() SecretResourceDescriptionList { + return page.srdl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SecretResourceDescriptionListPage) Values() []SecretResourceDescription { + if page.srdl.IsEmpty() { + return nil + } + return *page.srdl.Value +} + +// Creates a new instance of the SecretResourceDescriptionListPage type. +func NewSecretResourceDescriptionListPage(getNextPage func(context.Context, SecretResourceDescriptionList) (SecretResourceDescriptionList, error)) SecretResourceDescriptionListPage { + return SecretResourceDescriptionListPage{fn: getNextPage} +} + +// BasicSecretResourceProperties describes the properties of a secret resource. +type BasicSecretResourceProperties interface { + AsInlinedValueSecretResourceProperties() (*InlinedValueSecretResourceProperties, bool) + AsSecretResourceProperties() (*SecretResourceProperties, bool) +} + +// SecretResourceProperties describes the properties of a secret resource. +type SecretResourceProperties struct { + // Description - User readable description of the secret. + Description *string `json:"description,omitempty"` + // Status - READ-ONLY; Status of the resource. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the secret. + StatusDetails *string `json:"statusDetails,omitempty"` + // ContentType - The type of the content stored in the secret value. The value of this property is opaque to Service Fabric. Once set, the value of this property cannot be changed. + ContentType *string `json:"contentType,omitempty"` + // Kind - Possible values include: 'KindSecretResourcePropertiesBase', 'KindSecretResourceProperties', 'KindInlinedValue' + Kind Kind `json:"kind,omitempty"` + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +func unmarshalBasicSecretResourceProperties(body []byte) (BasicSecretResourceProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindInlinedValue): + var ivsrp InlinedValueSecretResourceProperties + err := json.Unmarshal(body, &ivsrp) + return ivsrp, err + default: + var srp SecretResourceProperties + err := json.Unmarshal(body, &srp) + return srp, err + } +} +func unmarshalBasicSecretResourcePropertiesArray(body []byte) ([]BasicSecretResourceProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + srpArray := make([]BasicSecretResourceProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + srp, err := unmarshalBasicSecretResourceProperties(*rawMessage) + if err != nil { + return nil, err + } + srpArray[index] = srp + } + return srpArray, nil +} + +// MarshalJSON is the custom marshaler for SecretResourceProperties. +func (srp SecretResourceProperties) MarshalJSON() ([]byte, error) { + srp.Kind = KindSecretResourceProperties + objectMap := make(map[string]interface{}) + if srp.Description != nil { + objectMap["description"] = srp.Description + } + if srp.ContentType != nil { + objectMap["contentType"] = srp.ContentType + } + if srp.Kind != "" { + objectMap["kind"] = srp.Kind + } + return json.Marshal(objectMap) +} + +// AsSecretResourceProperties is the BasicSecretResourcePropertiesBase implementation for SecretResourceProperties. +func (srp SecretResourceProperties) AsSecretResourceProperties() (*SecretResourceProperties, bool) { + return &srp, true +} + +// AsBasicSecretResourceProperties is the BasicSecretResourcePropertiesBase implementation for SecretResourceProperties. +func (srp SecretResourceProperties) AsBasicSecretResourceProperties() (BasicSecretResourceProperties, bool) { + return &srp, true +} + +// AsInlinedValueSecretResourceProperties is the BasicSecretResourcePropertiesBase implementation for SecretResourceProperties. +func (srp SecretResourceProperties) AsInlinedValueSecretResourceProperties() (*InlinedValueSecretResourceProperties, bool) { + return nil, false +} + +// AsSecretResourcePropertiesBase is the BasicSecretResourcePropertiesBase implementation for SecretResourceProperties. +func (srp SecretResourceProperties) AsSecretResourcePropertiesBase() (*SecretResourcePropertiesBase, bool) { + return nil, false +} + +// AsBasicSecretResourcePropertiesBase is the BasicSecretResourcePropertiesBase implementation for SecretResourceProperties. +func (srp SecretResourceProperties) AsBasicSecretResourcePropertiesBase() (BasicSecretResourcePropertiesBase, bool) { + return &srp, true +} + +// BasicSecretResourcePropertiesBase this type describes the properties of a secret resource, including its kind. +type BasicSecretResourcePropertiesBase interface { + AsSecretResourceProperties() (*SecretResourceProperties, bool) + AsBasicSecretResourceProperties() (BasicSecretResourceProperties, bool) + AsInlinedValueSecretResourceProperties() (*InlinedValueSecretResourceProperties, bool) + AsSecretResourcePropertiesBase() (*SecretResourcePropertiesBase, bool) +} + +// SecretResourcePropertiesBase this type describes the properties of a secret resource, including its kind. +type SecretResourcePropertiesBase struct { + // Kind - Possible values include: 'KindSecretResourcePropertiesBase', 'KindSecretResourceProperties', 'KindInlinedValue' + Kind Kind `json:"kind,omitempty"` + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +func unmarshalBasicSecretResourcePropertiesBase(body []byte) (BasicSecretResourcePropertiesBase, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["kind"] { + case string(KindSecretResourceProperties): + var srp SecretResourceProperties + err := json.Unmarshal(body, &srp) + return srp, err + case string(KindInlinedValue): + var ivsrp InlinedValueSecretResourceProperties + err := json.Unmarshal(body, &ivsrp) + return ivsrp, err + default: + var srpb SecretResourcePropertiesBase + err := json.Unmarshal(body, &srpb) + return srpb, err + } +} +func unmarshalBasicSecretResourcePropertiesBaseArray(body []byte) ([]BasicSecretResourcePropertiesBase, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + srpbArray := make([]BasicSecretResourcePropertiesBase, len(rawMessages)) + + for index, rawMessage := range rawMessages { + srpb, err := unmarshalBasicSecretResourcePropertiesBase(*rawMessage) + if err != nil { + return nil, err + } + srpbArray[index] = srpb + } + return srpbArray, nil +} + +// MarshalJSON is the custom marshaler for SecretResourcePropertiesBase. +func (srpb SecretResourcePropertiesBase) MarshalJSON() ([]byte, error) { + srpb.Kind = KindSecretResourcePropertiesBase + objectMap := make(map[string]interface{}) + if srpb.Kind != "" { + objectMap["kind"] = srpb.Kind + } + return json.Marshal(objectMap) +} + +// AsSecretResourceProperties is the BasicSecretResourcePropertiesBase implementation for SecretResourcePropertiesBase. +func (srpb SecretResourcePropertiesBase) AsSecretResourceProperties() (*SecretResourceProperties, bool) { + return nil, false +} + +// AsBasicSecretResourceProperties is the BasicSecretResourcePropertiesBase implementation for SecretResourcePropertiesBase. +func (srpb SecretResourcePropertiesBase) AsBasicSecretResourceProperties() (BasicSecretResourceProperties, bool) { + return nil, false +} + +// AsInlinedValueSecretResourceProperties is the BasicSecretResourcePropertiesBase implementation for SecretResourcePropertiesBase. +func (srpb SecretResourcePropertiesBase) AsInlinedValueSecretResourceProperties() (*InlinedValueSecretResourceProperties, bool) { + return nil, false +} + +// AsSecretResourcePropertiesBase is the BasicSecretResourcePropertiesBase implementation for SecretResourcePropertiesBase. +func (srpb SecretResourcePropertiesBase) AsSecretResourcePropertiesBase() (*SecretResourcePropertiesBase, bool) { + return &srpb, true +} + +// AsBasicSecretResourcePropertiesBase is the BasicSecretResourcePropertiesBase implementation for SecretResourcePropertiesBase. +func (srpb SecretResourcePropertiesBase) AsBasicSecretResourcePropertiesBase() (BasicSecretResourcePropertiesBase, bool) { + return &srpb, true +} + +// SecretValue this type represents the unencrypted value of the secret. +type SecretValue struct { + autorest.Response `json:"-"` + // Value - The actual value of the secret. + Value *string `json:"value,omitempty"` +} + +// SecretValueProperties this type describes properties of secret value resource. +type SecretValueProperties struct { + // Value - The actual value of the secret. + Value *string `json:"value,omitempty"` +} + +// SecretValueResourceDescription this type describes a value of a secret resource. The name of this +// resource is the version identifier corresponding to this secret value. +type SecretValueResourceDescription struct { + autorest.Response `json:"-"` + // SecretValueResourceProperties - This type describes properties of a secret value resource. + *SecretValueResourceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for SecretValueResourceDescription. +func (svrd SecretValueResourceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if svrd.SecretValueResourceProperties != nil { + objectMap["properties"] = svrd.SecretValueResourceProperties + } + if svrd.Tags != nil { + objectMap["tags"] = svrd.Tags + } + if svrd.Location != nil { + objectMap["location"] = svrd.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SecretValueResourceDescription struct. +func (svrd *SecretValueResourceDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var secretValueResourceProperties SecretValueResourceProperties + err = json.Unmarshal(*v, &secretValueResourceProperties) + if err != nil { + return err + } + svrd.SecretValueResourceProperties = &secretValueResourceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + svrd.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + svrd.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + svrd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + svrd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + svrd.Type = &typeVar + } + } + } + + return nil +} + +// SecretValueResourceDescriptionList a pageable list of values of a secret resource. The information does +// not include only the name of the value and not the actual unencrypted value. +type SecretValueResourceDescriptionList struct { + autorest.Response `json:"-"` + // Value - One page of the list. + Value *[]SecretValueResourceDescription `json:"value,omitempty"` + // NextLink - URI to fetch the next page of the list. + NextLink *string `json:"nextLink,omitempty"` +} + +// SecretValueResourceDescriptionListIterator provides access to a complete listing of +// SecretValueResourceDescription values. +type SecretValueResourceDescriptionListIterator struct { + i int + page SecretValueResourceDescriptionListPage +} + +// NextWithContext 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 *SecretValueResourceDescriptionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretValueResourceDescriptionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SecretValueResourceDescriptionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SecretValueResourceDescriptionListIterator) 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 SecretValueResourceDescriptionListIterator) Response() SecretValueResourceDescriptionList { + 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 SecretValueResourceDescriptionListIterator) Value() SecretValueResourceDescription { + if !iter.page.NotDone() { + return SecretValueResourceDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SecretValueResourceDescriptionListIterator type. +func NewSecretValueResourceDescriptionListIterator(page SecretValueResourceDescriptionListPage) SecretValueResourceDescriptionListIterator { + return SecretValueResourceDescriptionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (svrdl SecretValueResourceDescriptionList) IsEmpty() bool { + return svrdl.Value == nil || len(*svrdl.Value) == 0 +} + +// secretValueResourceDescriptionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (svrdl SecretValueResourceDescriptionList) secretValueResourceDescriptionListPreparer(ctx context.Context) (*http.Request, error) { + if svrdl.NextLink == nil || len(to.String(svrdl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(svrdl.NextLink))) +} + +// SecretValueResourceDescriptionListPage contains a page of SecretValueResourceDescription values. +type SecretValueResourceDescriptionListPage struct { + fn func(context.Context, SecretValueResourceDescriptionList) (SecretValueResourceDescriptionList, error) + svrdl SecretValueResourceDescriptionList +} + +// NextWithContext 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 *SecretValueResourceDescriptionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretValueResourceDescriptionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.svrdl) + if err != nil { + return err + } + page.svrdl = next + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *SecretValueResourceDescriptionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SecretValueResourceDescriptionListPage) NotDone() bool { + return !page.svrdl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SecretValueResourceDescriptionListPage) Response() SecretValueResourceDescriptionList { + return page.svrdl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SecretValueResourceDescriptionListPage) Values() []SecretValueResourceDescription { + if page.svrdl.IsEmpty() { + return nil + } + return *page.svrdl.Value +} + +// Creates a new instance of the SecretValueResourceDescriptionListPage type. +func NewSecretValueResourceDescriptionListPage(getNextPage func(context.Context, SecretValueResourceDescriptionList) (SecretValueResourceDescriptionList, error)) SecretValueResourceDescriptionListPage { + return SecretValueResourceDescriptionListPage{fn: getNextPage} +} + +// SecretValueResourceProperties this type describes properties of a secret value resource. +type SecretValueResourceProperties struct { + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Value - The actual value of the secret. + Value *string `json:"value,omitempty"` +} + +// ServiceProperties describes properties of a service resource. +type ServiceProperties struct { + // Description - User readable description of the service. + Description *string `json:"description,omitempty"` + // ReplicaCount - The number of replicas of the service to create. Defaults to 1 if not specified. + ReplicaCount *int32 `json:"replicaCount,omitempty"` + // AutoScalingPolicies - Auto scaling policies + AutoScalingPolicies *[]AutoScalingPolicy `json:"autoScalingPolicies,omitempty"` + // Status - READ-ONLY; Status of the service. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the service. + StatusDetails *string `json:"statusDetails,omitempty"` + // HealthState - READ-ONLY; Describes the health state of an application resource. Possible values include: 'HealthStateInvalid', 'HealthStateOk', 'HealthStateWarning', 'HealthStateError', 'HealthStateUnknown' + HealthState HealthState `json:"healthState,omitempty"` + // UnhealthyEvaluation - READ-ONLY; When the service's health state is not 'Ok', this additional details from service fabric Health Manager for the user to know why the service is marked unhealthy. + UnhealthyEvaluation *string `json:"unhealthyEvaluation,omitempty"` +} + +// ServiceReplicaDescription describes a replica of a service resource. +type ServiceReplicaDescription struct { + autorest.Response `json:"-"` + // ReplicaName - Name of the replica. + ReplicaName *string `json:"replicaName,omitempty"` + // OsType - The operation system required by the code in service. Possible values include: 'Linux', 'Windows' + OsType OperatingSystemType `json:"osType,omitempty"` + // CodePackages - Describes the set of code packages that forms the service. A code package describes the container and the properties for running it. All the code packages are started together on the same host and share the same context (network, process etc.). + CodePackages *[]ContainerCodePackageProperties `json:"codePackages,omitempty"` + // NetworkRefs - The names of the private networks that this service needs to be part of. + NetworkRefs *[]NetworkRef `json:"networkRefs,omitempty"` + // Diagnostics - Reference to sinks in DiagnosticsDescription. + Diagnostics *DiagnosticsRef `json:"diagnostics,omitempty"` +} + +// ServiceReplicaDescriptionList a pageable list of service replicas. +type ServiceReplicaDescriptionList struct { + autorest.Response `json:"-"` + // Value - One page of the list. + Value *[]ServiceReplicaDescription `json:"value,omitempty"` + // NextLink - URI to fetch the next page of the list. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServiceReplicaDescriptionListIterator provides access to a complete listing of ServiceReplicaDescription +// values. +type ServiceReplicaDescriptionListIterator struct { + i int + page ServiceReplicaDescriptionListPage +} + +// NextWithContext 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 *ServiceReplicaDescriptionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceReplicaDescriptionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServiceReplicaDescriptionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServiceReplicaDescriptionListIterator) 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 ServiceReplicaDescriptionListIterator) Response() ServiceReplicaDescriptionList { + 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 ServiceReplicaDescriptionListIterator) Value() ServiceReplicaDescription { + if !iter.page.NotDone() { + return ServiceReplicaDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServiceReplicaDescriptionListIterator type. +func NewServiceReplicaDescriptionListIterator(page ServiceReplicaDescriptionListPage) ServiceReplicaDescriptionListIterator { + return ServiceReplicaDescriptionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (srdl ServiceReplicaDescriptionList) IsEmpty() bool { + return srdl.Value == nil || len(*srdl.Value) == 0 +} + +// serviceReplicaDescriptionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (srdl ServiceReplicaDescriptionList) serviceReplicaDescriptionListPreparer(ctx context.Context) (*http.Request, error) { + if srdl.NextLink == nil || len(to.String(srdl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(srdl.NextLink))) +} + +// ServiceReplicaDescriptionListPage contains a page of ServiceReplicaDescription values. +type ServiceReplicaDescriptionListPage struct { + fn func(context.Context, ServiceReplicaDescriptionList) (ServiceReplicaDescriptionList, error) + srdl ServiceReplicaDescriptionList +} + +// NextWithContext 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 *ServiceReplicaDescriptionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceReplicaDescriptionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.srdl) + if err != nil { + return err + } + page.srdl = next + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServiceReplicaDescriptionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServiceReplicaDescriptionListPage) NotDone() bool { + return !page.srdl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServiceReplicaDescriptionListPage) Response() ServiceReplicaDescriptionList { + return page.srdl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServiceReplicaDescriptionListPage) Values() []ServiceReplicaDescription { + if page.srdl.IsEmpty() { + return nil + } + return *page.srdl.Value +} + +// Creates a new instance of the ServiceReplicaDescriptionListPage type. +func NewServiceReplicaDescriptionListPage(getNextPage func(context.Context, ServiceReplicaDescriptionList) (ServiceReplicaDescriptionList, error)) ServiceReplicaDescriptionListPage { + return ServiceReplicaDescriptionListPage{fn: getNextPage} +} + +// ServiceReplicaProperties describes the properties of a service replica. +type ServiceReplicaProperties struct { + // OsType - The operation system required by the code in service. Possible values include: 'Linux', 'Windows' + OsType OperatingSystemType `json:"osType,omitempty"` + // CodePackages - Describes the set of code packages that forms the service. A code package describes the container and the properties for running it. All the code packages are started together on the same host and share the same context (network, process etc.). + CodePackages *[]ContainerCodePackageProperties `json:"codePackages,omitempty"` + // NetworkRefs - The names of the private networks that this service needs to be part of. + NetworkRefs *[]NetworkRef `json:"networkRefs,omitempty"` + // Diagnostics - Reference to sinks in DiagnosticsDescription. + Diagnostics *DiagnosticsRef `json:"diagnostics,omitempty"` +} + +// ServiceResourceDescription this type describes a service resource. +type ServiceResourceDescription struct { + autorest.Response `json:"-"` + // ServiceResourceProperties - This type describes properties of a service resource. + *ServiceResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceResourceDescription. +func (srd ServiceResourceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if srd.ServiceResourceProperties != nil { + objectMap["properties"] = srd.ServiceResourceProperties + } + if srd.Name != nil { + objectMap["name"] = srd.Name + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceResourceDescription struct. +func (srd *ServiceResourceDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var serviceResourceProperties ServiceResourceProperties + err = json.Unmarshal(*v, &serviceResourceProperties) + if err != nil { + return err + } + srd.ServiceResourceProperties = &serviceResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + srd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + srd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + srd.Type = &typeVar + } + } + } + + return nil +} + +// ServiceResourceDescriptionList a pageable list of service resources. +type ServiceResourceDescriptionList struct { + autorest.Response `json:"-"` + // Value - One page of the list. + Value *[]ServiceResourceDescription `json:"value,omitempty"` + // NextLink - URI to fetch the next page of the list. + NextLink *string `json:"nextLink,omitempty"` +} + +// ServiceResourceDescriptionListIterator provides access to a complete listing of +// ServiceResourceDescription values. +type ServiceResourceDescriptionListIterator struct { + i int + page ServiceResourceDescriptionListPage +} + +// NextWithContext 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 *ServiceResourceDescriptionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceResourceDescriptionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServiceResourceDescriptionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServiceResourceDescriptionListIterator) 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 ServiceResourceDescriptionListIterator) Response() ServiceResourceDescriptionList { + 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 ServiceResourceDescriptionListIterator) Value() ServiceResourceDescription { + if !iter.page.NotDone() { + return ServiceResourceDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServiceResourceDescriptionListIterator type. +func NewServiceResourceDescriptionListIterator(page ServiceResourceDescriptionListPage) ServiceResourceDescriptionListIterator { + return ServiceResourceDescriptionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (srdl ServiceResourceDescriptionList) IsEmpty() bool { + return srdl.Value == nil || len(*srdl.Value) == 0 +} + +// serviceResourceDescriptionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (srdl ServiceResourceDescriptionList) serviceResourceDescriptionListPreparer(ctx context.Context) (*http.Request, error) { + if srdl.NextLink == nil || len(to.String(srdl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(srdl.NextLink))) +} + +// ServiceResourceDescriptionListPage contains a page of ServiceResourceDescription values. +type ServiceResourceDescriptionListPage struct { + fn func(context.Context, ServiceResourceDescriptionList) (ServiceResourceDescriptionList, error) + srdl ServiceResourceDescriptionList +} + +// NextWithContext 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 *ServiceResourceDescriptionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceResourceDescriptionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.srdl) + if err != nil { + return err + } + page.srdl = next + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *ServiceResourceDescriptionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServiceResourceDescriptionListPage) NotDone() bool { + return !page.srdl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServiceResourceDescriptionListPage) Response() ServiceResourceDescriptionList { + return page.srdl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServiceResourceDescriptionListPage) Values() []ServiceResourceDescription { + if page.srdl.IsEmpty() { + return nil + } + return *page.srdl.Value +} + +// Creates a new instance of the ServiceResourceDescriptionListPage type. +func NewServiceResourceDescriptionListPage(getNextPage func(context.Context, ServiceResourceDescriptionList) (ServiceResourceDescriptionList, error)) ServiceResourceDescriptionListPage { + return ServiceResourceDescriptionListPage{fn: getNextPage} +} + +// ServiceResourceProperties this type describes properties of a service resource. +type ServiceResourceProperties struct { + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` + // OsType - The operation system required by the code in service. Possible values include: 'Linux', 'Windows' + OsType OperatingSystemType `json:"osType,omitempty"` + // CodePackages - Describes the set of code packages that forms the service. A code package describes the container and the properties for running it. All the code packages are started together on the same host and share the same context (network, process etc.). + CodePackages *[]ContainerCodePackageProperties `json:"codePackages,omitempty"` + // NetworkRefs - The names of the private networks that this service needs to be part of. + NetworkRefs *[]NetworkRef `json:"networkRefs,omitempty"` + // Diagnostics - Reference to sinks in DiagnosticsDescription. + Diagnostics *DiagnosticsRef `json:"diagnostics,omitempty"` + // Description - User readable description of the service. + Description *string `json:"description,omitempty"` + // ReplicaCount - The number of replicas of the service to create. Defaults to 1 if not specified. + ReplicaCount *int32 `json:"replicaCount,omitempty"` + // AutoScalingPolicies - Auto scaling policies + AutoScalingPolicies *[]AutoScalingPolicy `json:"autoScalingPolicies,omitempty"` + // Status - READ-ONLY; Status of the service. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the service. + StatusDetails *string `json:"statusDetails,omitempty"` + // HealthState - READ-ONLY; Describes the health state of an application resource. Possible values include: 'HealthStateInvalid', 'HealthStateOk', 'HealthStateWarning', 'HealthStateError', 'HealthStateUnknown' + HealthState HealthState `json:"healthState,omitempty"` + // UnhealthyEvaluation - READ-ONLY; When the service's health state is not 'Ok', this additional details from service fabric Health Manager for the user to know why the service is marked unhealthy. + UnhealthyEvaluation *string `json:"unhealthyEvaluation,omitempty"` +} + +// Setting describes a setting for the container. The setting file path can be fetched from environment +// variable "Fabric_SettingPath". The path for Windows container is "C:\\secrets". The path for Linux +// container is "/var/secrets". +type Setting struct { + // Name - The name of the setting. + Name *string `json:"name,omitempty"` + // Value - The value of the setting. + Value *string `json:"value,omitempty"` +} + +// TCPConfig describes the tcp configuration for external connectivity for this network. +type TCPConfig struct { + // Name - tcp gateway config name. + Name *string `json:"name,omitempty"` + // Port - Specifies the port at which the service endpoint below needs to be exposed. + Port *int32 `json:"port,omitempty"` + // Destination - Describes destination endpoint for routing traffic. + Destination *GatewayDestination `json:"destination,omitempty"` +} + +// TrackedResource the resource model definition for Azure Resource Manager tracked top-level resource. +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// VolumeProperties describes properties of a volume resource. +type VolumeProperties struct { + // Description - User readable description of the volume. + Description *string `json:"description,omitempty"` + // Status - READ-ONLY; Status of the volume. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the volume. + StatusDetails *string `json:"statusDetails,omitempty"` + // Provider - Provider of the volume. + Provider *string `json:"provider,omitempty"` + // AzureFileParameters - This type describes a volume provided by an Azure Files file share. + AzureFileParameters *VolumeProviderParametersAzureFile `json:"azureFileParameters,omitempty"` +} + +// VolumeProviderParametersAzureFile this type describes a volume provided by an Azure Files file share. +type VolumeProviderParametersAzureFile struct { + // AccountName - Name of the Azure storage account for the File Share. + AccountName *string `json:"accountName,omitempty"` + // AccountKey - Access key of the Azure storage account for the File Share. + AccountKey *string `json:"accountKey,omitempty"` + // ShareName - Name of the Azure Files file share that provides storage for the volume. + ShareName *string `json:"shareName,omitempty"` +} + +// VolumeReference describes a reference to a volume resource. +type VolumeReference struct { + // Name - Name of the volume being referenced. + Name *string `json:"name,omitempty"` + // ReadOnly - The flag indicating whether the volume is read only. Default is 'false'. + ReadOnly *bool `json:"readOnly,omitempty"` + // DestinationPath - The path within the container at which the volume should be mounted. Only valid path characters are allowed. + DestinationPath *string `json:"destinationPath,omitempty"` +} + +// VolumeResourceDescription this type describes a volume resource. +type VolumeResourceDescription struct { + autorest.Response `json:"-"` + // VolumeResourceProperties - This type describes properties of a volume resource. + *VolumeResourceProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified identifier for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for VolumeResourceDescription. +func (vrd VolumeResourceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vrd.VolumeResourceProperties != nil { + objectMap["properties"] = vrd.VolumeResourceProperties + } + if vrd.Tags != nil { + objectMap["tags"] = vrd.Tags + } + if vrd.Location != nil { + objectMap["location"] = vrd.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for VolumeResourceDescription struct. +func (vrd *VolumeResourceDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var volumeResourceProperties VolumeResourceProperties + err = json.Unmarshal(*v, &volumeResourceProperties) + if err != nil { + return err + } + vrd.VolumeResourceProperties = &volumeResourceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + vrd.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + vrd.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vrd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vrd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vrd.Type = &typeVar + } + } + } + + return nil +} + +// VolumeResourceDescriptionList a pageable list of volume resources. +type VolumeResourceDescriptionList struct { + autorest.Response `json:"-"` + // Value - One page of the list. + Value *[]VolumeResourceDescription `json:"value,omitempty"` + // NextLink - URI to fetch the next page of the list. + NextLink *string `json:"nextLink,omitempty"` +} + +// VolumeResourceDescriptionListIterator provides access to a complete listing of VolumeResourceDescription +// values. +type VolumeResourceDescriptionListIterator struct { + i int + page VolumeResourceDescriptionListPage +} + +// NextWithContext 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 *VolumeResourceDescriptionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeResourceDescriptionListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *VolumeResourceDescriptionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter VolumeResourceDescriptionListIterator) 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 VolumeResourceDescriptionListIterator) Response() VolumeResourceDescriptionList { + 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 VolumeResourceDescriptionListIterator) Value() VolumeResourceDescription { + if !iter.page.NotDone() { + return VolumeResourceDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the VolumeResourceDescriptionListIterator type. +func NewVolumeResourceDescriptionListIterator(page VolumeResourceDescriptionListPage) VolumeResourceDescriptionListIterator { + return VolumeResourceDescriptionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vrdl VolumeResourceDescriptionList) IsEmpty() bool { + return vrdl.Value == nil || len(*vrdl.Value) == 0 +} + +// volumeResourceDescriptionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vrdl VolumeResourceDescriptionList) volumeResourceDescriptionListPreparer(ctx context.Context) (*http.Request, error) { + if vrdl.NextLink == nil || len(to.String(vrdl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vrdl.NextLink))) +} + +// VolumeResourceDescriptionListPage contains a page of VolumeResourceDescription values. +type VolumeResourceDescriptionListPage struct { + fn func(context.Context, VolumeResourceDescriptionList) (VolumeResourceDescriptionList, error) + vrdl VolumeResourceDescriptionList +} + +// NextWithContext 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 *VolumeResourceDescriptionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeResourceDescriptionListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.vrdl) + if err != nil { + return err + } + page.vrdl = next + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *VolumeResourceDescriptionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page VolumeResourceDescriptionListPage) NotDone() bool { + return !page.vrdl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page VolumeResourceDescriptionListPage) Response() VolumeResourceDescriptionList { + return page.vrdl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page VolumeResourceDescriptionListPage) Values() []VolumeResourceDescription { + if page.vrdl.IsEmpty() { + return nil + } + return *page.vrdl.Value +} + +// Creates a new instance of the VolumeResourceDescriptionListPage type. +func NewVolumeResourceDescriptionListPage(getNextPage func(context.Context, VolumeResourceDescriptionList) (VolumeResourceDescriptionList, error)) VolumeResourceDescriptionListPage { + return VolumeResourceDescriptionListPage{fn: getNextPage} +} + +// VolumeResourceProperties this type describes properties of a volume resource. +type VolumeResourceProperties struct { + // ProvisioningState - READ-ONLY; State of the resource. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Description - User readable description of the volume. + Description *string `json:"description,omitempty"` + // Status - READ-ONLY; Status of the volume. Possible values include: 'Unknown', 'Ready', 'Upgrading', 'Creating', 'Deleting', 'Failed' + Status ResourceStatus `json:"status,omitempty"` + // StatusDetails - READ-ONLY; Gives additional information about the current status of the volume. + StatusDetails *string `json:"statusDetails,omitempty"` + // Provider - Provider of the volume. + Provider *string `json:"provider,omitempty"` + // AzureFileParameters - This type describes a volume provided by an Azure Files file share. + AzureFileParameters *VolumeProviderParametersAzureFile `json:"azureFileParameters,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/network.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/network.go new file mode 100644 index 000000000000..113f5b7e7401 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/network.go @@ -0,0 +1,504 @@ +package servicefabricmesh + +// 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" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// NetworkClient is the service Fabric Mesh Management Client +type NetworkClient struct { + BaseClient +} + +// NewNetworkClient creates an instance of the NetworkClient client. +func NewNetworkClient(subscriptionID string) NetworkClient { + return NewNetworkClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewNetworkClientWithBaseURI creates an instance of the NetworkClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewNetworkClientWithBaseURI(baseURI string, subscriptionID string) NetworkClient { + return NetworkClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a network resource with the specified name, description and properties. If a network resource with +// the same name exists, then it is updated with the specified description and properties. +// Parameters: +// resourceGroupName - azure resource group name +// networkResourceName - the identity of the network. +// networkResourceDescription - description for creating a Network resource. +func (client NetworkClient) Create(ctx context.Context, resourceGroupName string, networkResourceName string, networkResourceDescription NetworkResourceDescription) (result NetworkResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: networkResourceDescription, + Constraints: []validation.Constraint{{Target: "networkResourceDescription.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("servicefabricmesh.NetworkClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, networkResourceName, networkResourceDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client NetworkClient) CreatePreparer(ctx context.Context, resourceGroupName string, networkResourceName string, networkResourceDescription NetworkResourceDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkResourceName": networkResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/networks/{networkResourceName}", pathParameters), + autorest.WithJSON(networkResourceDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client NetworkClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client NetworkClient) CreateResponder(resp *http.Response) (result NetworkResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the network resource identified by the name. +// Parameters: +// resourceGroupName - azure resource group name +// networkResourceName - the identity of the network. +func (client NetworkClient) Delete(ctx context.Context, resourceGroupName string, networkResourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, networkResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client NetworkClient) DeletePreparer(ctx context.Context, resourceGroupName string, networkResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkResourceName": networkResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/networks/{networkResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client NetworkClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client NetworkClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the information about the network resource with the given name. The information include the description and +// other properties of the network. +// Parameters: +// resourceGroupName - azure resource group name +// networkResourceName - the identity of the network. +func (client NetworkClient) Get(ctx context.Context, resourceGroupName string, networkResourceName string) (result NetworkResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, networkResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client NetworkClient) GetPreparer(ctx context.Context, resourceGroupName string, networkResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "networkResourceName": networkResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/networks/{networkResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client NetworkClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client NetworkClient) GetResponder(resp *http.Response) (result NetworkResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup gets the information about all network resources in a given resource group. The information +// include the description and other properties of the Network. +// Parameters: +// resourceGroupName - azure resource group name +func (client NetworkClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result NetworkResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.nrdl.Response.Response != nil { + sc = result.nrdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.nrdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.nrdl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client NetworkClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/networks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client NetworkClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client NetworkClient) ListByResourceGroupResponder(resp *http.Response) (result NetworkResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client NetworkClient) listByResourceGroupNextResults(ctx context.Context, lastResults NetworkResourceDescriptionList) (result NetworkResourceDescriptionList, err error) { + req, err := lastResults.networkResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client NetworkClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result NetworkResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription gets the information about all network resources in a given resource group. The information +// include the description and other properties of the network. +func (client NetworkClient) ListBySubscription(ctx context.Context) (result NetworkResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkClient.ListBySubscription") + defer func() { + sc := -1 + if result.nrdl.Response.Response != nil { + sc = result.nrdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.nrdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.nrdl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client NetworkClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabricMesh/networks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client NetworkClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client NetworkClient) ListBySubscriptionResponder(resp *http.Response) (result NetworkResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client NetworkClient) listBySubscriptionNextResults(ctx context.Context, lastResults NetworkResourceDescriptionList) (result NetworkResourceDescriptionList, err error) { + req, err := lastResults.networkResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.NetworkClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client NetworkClient) ListBySubscriptionComplete(ctx context.Context) (result NetworkResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NetworkClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/operations.go new file mode 100644 index 000000000000..a625b8abe69f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/operations.go @@ -0,0 +1,147 @@ +package servicefabricmesh + +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the service Fabric Mesh Management Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all the available operations provided by Service Fabric SeaBreeze resource provider. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ServiceFabricMesh/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/secret.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/secret.go new file mode 100644 index 000000000000..aac493fd8252 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/secret.go @@ -0,0 +1,504 @@ +package servicefabricmesh + +// 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" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SecretClient is the service Fabric Mesh Management Client +type SecretClient struct { + BaseClient +} + +// NewSecretClient creates an instance of the SecretClient client. +func NewSecretClient(subscriptionID string) SecretClient { + return NewSecretClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSecretClientWithBaseURI creates an instance of the SecretClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSecretClientWithBaseURI(baseURI string, subscriptionID string) SecretClient { + return SecretClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a secret resource with the specified name, description and properties. If a secret resource with the +// same name exists, then it is updated with the specified description and properties. +// Parameters: +// resourceGroupName - azure resource group name +// secretResourceName - the name of the secret resource. +// secretResourceDescription - description for creating a secret resource. +func (client SecretClient) Create(ctx context.Context, resourceGroupName string, secretResourceName string, secretResourceDescription SecretResourceDescription) (result SecretResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: secretResourceDescription, + Constraints: []validation.Constraint{{Target: "secretResourceDescription.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("servicefabricmesh.SecretClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, secretResourceName, secretResourceDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SecretClient) CreatePreparer(ctx context.Context, resourceGroupName string, secretResourceName string, secretResourceDescription SecretResourceDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "secretResourceName": secretResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/secrets/{secretResourceName}", pathParameters), + autorest.WithJSON(secretResourceDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SecretClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SecretClient) CreateResponder(resp *http.Response) (result SecretResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the secret resource identified by the name. +// Parameters: +// resourceGroupName - azure resource group name +// secretResourceName - the name of the secret resource. +func (client SecretClient) Delete(ctx context.Context, resourceGroupName string, secretResourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, secretResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SecretClient) DeletePreparer(ctx context.Context, resourceGroupName string, secretResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "secretResourceName": secretResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/secrets/{secretResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SecretClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SecretClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the information about the secret resource with the given name. The information include the description and +// other properties of the secret. +// Parameters: +// resourceGroupName - azure resource group name +// secretResourceName - the name of the secret resource. +func (client SecretClient) Get(ctx context.Context, resourceGroupName string, secretResourceName string) (result SecretResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, secretResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SecretClient) GetPreparer(ctx context.Context, resourceGroupName string, secretResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "secretResourceName": secretResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/secrets/{secretResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SecretClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SecretClient) GetResponder(resp *http.Response) (result SecretResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup gets the information about all secret resources in a given resource group. The information +// include the description and other properties of the Secret. +// Parameters: +// resourceGroupName - azure resource group name +func (client SecretClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result SecretResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.srdl.Response.Response != nil { + sc = result.srdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.srdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.srdl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client SecretClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/secrets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client SecretClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client SecretClient) ListByResourceGroupResponder(resp *http.Response) (result SecretResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client SecretClient) listByResourceGroupNextResults(ctx context.Context, lastResults SecretResourceDescriptionList) (result SecretResourceDescriptionList, err error) { + req, err := lastResults.secretResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client SecretClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result SecretResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription gets the information about all secret resources in a given resource group. The information +// include the description and other properties of the secret. +func (client SecretClient) ListBySubscription(ctx context.Context) (result SecretResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretClient.ListBySubscription") + defer func() { + sc := -1 + if result.srdl.Response.Response != nil { + sc = result.srdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.srdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.srdl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client SecretClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabricMesh/secrets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client SecretClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client SecretClient) ListBySubscriptionResponder(resp *http.Response) (result SecretResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client SecretClient) listBySubscriptionNextResults(ctx context.Context, lastResults SecretResourceDescriptionList) (result SecretResourceDescriptionList, err error) { + req, err := lastResults.secretResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client SecretClient) ListBySubscriptionComplete(ctx context.Context) (result SecretResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/secretvalue.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/secretvalue.go new file mode 100644 index 000000000000..8a1b208f9b1f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/secretvalue.go @@ -0,0 +1,486 @@ +package servicefabricmesh + +// 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" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SecretValueClient is the service Fabric Mesh Management Client +type SecretValueClient struct { + BaseClient +} + +// NewSecretValueClient creates an instance of the SecretValueClient client. +func NewSecretValueClient(subscriptionID string) SecretValueClient { + return NewSecretValueClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSecretValueClientWithBaseURI creates an instance of the SecretValueClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSecretValueClientWithBaseURI(baseURI string, subscriptionID string) SecretValueClient { + return SecretValueClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a new value of the specified secret resource. The name of the value is typically the version +// identifier. Once created the value cannot be changed. +// Parameters: +// resourceGroupName - azure resource group name +// secretResourceName - the name of the secret resource. +// secretValueResourceName - the name of the secret resource value which is typically the version identifier +// for the value. +// secretValueResourceDescription - description for creating a value of a secret resource. +func (client SecretValueClient) Create(ctx context.Context, resourceGroupName string, secretResourceName string, secretValueResourceName string, secretValueResourceDescription SecretValueResourceDescription) (result SecretValueResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretValueClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: secretValueResourceDescription, + Constraints: []validation.Constraint{{Target: "secretValueResourceDescription.SecretValueResourceProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("servicefabricmesh.SecretValueClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, secretResourceName, secretValueResourceName, secretValueResourceDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SecretValueClient) CreatePreparer(ctx context.Context, resourceGroupName string, secretResourceName string, secretValueResourceName string, secretValueResourceDescription SecretValueResourceDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "secretResourceName": secretResourceName, + "secretValueResourceName": secretValueResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/secrets/{secretResourceName}/values/{secretValueResourceName}", pathParameters), + autorest.WithJSON(secretValueResourceDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SecretValueClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SecretValueClient) CreateResponder(resp *http.Response) (result SecretValueResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the secret value resource identified by the name. The name of the resource is typically the version +// associated with that value. Deletion will fail if the specified value is in use. +// Parameters: +// resourceGroupName - azure resource group name +// secretResourceName - the name of the secret resource. +// secretValueResourceName - the name of the secret resource value which is typically the version identifier +// for the value. +func (client SecretValueClient) Delete(ctx context.Context, resourceGroupName string, secretResourceName string, secretValueResourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretValueClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, secretResourceName, secretValueResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SecretValueClient) DeletePreparer(ctx context.Context, resourceGroupName string, secretResourceName string, secretValueResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "secretResourceName": secretResourceName, + "secretValueResourceName": secretValueResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/secrets/{secretResourceName}/values/{secretValueResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client SecretValueClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client SecretValueClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the information about the specified named secret value resources. The information does not include the +// actual value of the secret. +// Parameters: +// resourceGroupName - azure resource group name +// secretResourceName - the name of the secret resource. +// secretValueResourceName - the name of the secret resource value which is typically the version identifier +// for the value. +func (client SecretValueClient) Get(ctx context.Context, resourceGroupName string, secretResourceName string, secretValueResourceName string) (result SecretValueResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretValueClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, secretResourceName, secretValueResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SecretValueClient) GetPreparer(ctx context.Context, resourceGroupName string, secretResourceName string, secretValueResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "secretResourceName": secretResourceName, + "secretValueResourceName": secretValueResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/secrets/{secretResourceName}/values/{secretValueResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client SecretValueClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SecretValueClient) GetResponder(resp *http.Response) (result SecretValueResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets information about all secret value resources of the specified secret resource. The information includes +// the names of the secret value resources, but not the actual values. +// Parameters: +// resourceGroupName - azure resource group name +// secretResourceName - the name of the secret resource. +func (client SecretValueClient) List(ctx context.Context, resourceGroupName string, secretResourceName string) (result SecretValueResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretValueClient.List") + defer func() { + sc := -1 + if result.svrdl.Response.Response != nil { + sc = result.svrdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, secretResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.svrdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "List", resp, "Failure sending request") + return + } + + result.svrdl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SecretValueClient) ListPreparer(ctx context.Context, resourceGroupName string, secretResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "secretResourceName": secretResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/secrets/{secretResourceName}/values", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SecretValueClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SecretValueClient) ListResponder(resp *http.Response) (result SecretValueResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SecretValueClient) listNextResults(ctx context.Context, lastResults SecretValueResourceDescriptionList) (result SecretValueResourceDescriptionList, err error) { + req, err := lastResults.secretValueResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SecretValueClient) ListComplete(ctx context.Context, resourceGroupName string, secretResourceName string) (result SecretValueResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretValueClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, secretResourceName) + return +} + +// ListValue lists the decrypted value of the specified named value of the secret resource. This is a privileged +// operation. +// Parameters: +// resourceGroupName - azure resource group name +// secretResourceName - the name of the secret resource. +// secretValueResourceName - the name of the secret resource value which is typically the version identifier +// for the value. +func (client SecretValueClient) ListValue(ctx context.Context, resourceGroupName string, secretResourceName string, secretValueResourceName string) (result SecretValue, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SecretValueClient.ListValue") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListValuePreparer(ctx, resourceGroupName, secretResourceName, secretValueResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "ListValue", nil, "Failure preparing request") + return + } + + resp, err := client.ListValueSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "ListValue", resp, "Failure sending request") + return + } + + result, err = client.ListValueResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.SecretValueClient", "ListValue", resp, "Failure responding to request") + } + + return +} + +// ListValuePreparer prepares the ListValue request. +func (client SecretValueClient) ListValuePreparer(ctx context.Context, resourceGroupName string, secretResourceName string, secretValueResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "secretResourceName": secretResourceName, + "secretValueResourceName": secretValueResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/secrets/{secretResourceName}/values/{secretValueResourceName}/list_value", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListValueSender sends the ListValue request. The method will close the +// http.Response Body if it receives an error. +func (client SecretValueClient) ListValueSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListValueResponder handles the response to the ListValue request. The method always +// closes the http.Response Body. +func (client SecretValueClient) ListValueResponder(resp *http.Response) (result SecretValue, 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/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/service.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/service.go new file mode 100644 index 000000000000..7e53f3d99d3e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/service.go @@ -0,0 +1,236 @@ +package servicefabricmesh + +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServiceClient is the service Fabric Mesh Management Client +type ServiceClient struct { + BaseClient +} + +// NewServiceClient creates an instance of the ServiceClient client. +func NewServiceClient(subscriptionID string) ServiceClient { + return NewServiceClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceClientWithBaseURI creates an instance of the ServiceClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServiceClientWithBaseURI(baseURI string, subscriptionID string) ServiceClient { + return ServiceClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the information about the service resource with the given name. The information include the description and +// other properties of the service. +// Parameters: +// resourceGroupName - azure resource group name +// applicationResourceName - the identity of the application. +// serviceResourceName - the identity of the service. +func (client ServiceClient) Get(ctx context.Context, resourceGroupName string, applicationResourceName string, serviceResourceName string) (result ServiceResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, applicationResourceName, serviceResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServiceClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationResourceName string, serviceResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationResourceName": applicationResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceResourceName": serviceResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/applications/{applicationResourceName}/services/{serviceResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceClient) GetResponder(resp *http.Response) (result ServiceResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the information about all services of an application resource. The information include the description and +// other properties of the Service. +// Parameters: +// resourceGroupName - azure resource group name +// applicationResourceName - the identity of the application. +func (client ServiceClient) List(ctx context.Context, resourceGroupName string, applicationResourceName string) (result ServiceResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.List") + defer func() { + sc := -1 + if result.srdl.Response.Response != nil { + sc = result.srdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, applicationResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.srdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceClient", "List", resp, "Failure sending request") + return + } + + result.srdl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ServiceClient) ListPreparer(ctx context.Context, resourceGroupName string, applicationResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationResourceName": applicationResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/applications/{applicationResourceName}/services", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceClient) ListResponder(resp *http.Response) (result ServiceResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ServiceClient) listNextResults(ctx context.Context, lastResults ServiceResourceDescriptionList) (result ServiceResourceDescriptionList, err error) { + req, err := lastResults.serviceResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.ServiceClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.ServiceClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceClient) ListComplete(ctx context.Context, resourceGroupName string, applicationResourceName string) (result ServiceResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, applicationResourceName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/servicereplica.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/servicereplica.go new file mode 100644 index 000000000000..c2aaa3880559 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/servicereplica.go @@ -0,0 +1,240 @@ +package servicefabricmesh + +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServiceReplicaClient is the service Fabric Mesh Management Client +type ServiceReplicaClient struct { + BaseClient +} + +// NewServiceReplicaClient creates an instance of the ServiceReplicaClient client. +func NewServiceReplicaClient(subscriptionID string) ServiceReplicaClient { + return NewServiceReplicaClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServiceReplicaClientWithBaseURI creates an instance of the ServiceReplicaClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServiceReplicaClientWithBaseURI(baseURI string, subscriptionID string) ServiceReplicaClient { + return ServiceReplicaClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the information about the service replica with the given name. The information include the description and +// other properties of the service replica. +// Parameters: +// resourceGroupName - azure resource group name +// applicationResourceName - the identity of the application. +// serviceResourceName - the identity of the service. +// replicaName - service Fabric replica name. +func (client ServiceReplicaClient) Get(ctx context.Context, resourceGroupName string, applicationResourceName string, serviceResourceName string, replicaName string) (result ServiceReplicaDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceReplicaClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, applicationResourceName, serviceResourceName, replicaName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceReplicaClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceReplicaClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceReplicaClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServiceReplicaClient) GetPreparer(ctx context.Context, resourceGroupName string, applicationResourceName string, serviceResourceName string, replicaName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationResourceName": applicationResourceName, + "replicaName": replicaName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceResourceName": serviceResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/applications/{applicationResourceName}/services/{serviceResourceName}/replicas/{replicaName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceReplicaClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServiceReplicaClient) GetResponder(resp *http.Response) (result ServiceReplicaDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the information about all replicas of a given service of an application. The information includes the +// runtime properties of the replica instance. +// Parameters: +// resourceGroupName - azure resource group name +// applicationResourceName - the identity of the application. +// serviceResourceName - the identity of the service. +func (client ServiceReplicaClient) List(ctx context.Context, resourceGroupName string, applicationResourceName string, serviceResourceName string) (result ServiceReplicaDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceReplicaClient.List") + defer func() { + sc := -1 + if result.srdl.Response.Response != nil { + sc = result.srdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, applicationResourceName, serviceResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceReplicaClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.srdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceReplicaClient", "List", resp, "Failure sending request") + return + } + + result.srdl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceReplicaClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ServiceReplicaClient) ListPreparer(ctx context.Context, resourceGroupName string, applicationResourceName string, serviceResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationResourceName": applicationResourceName, + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceResourceName": serviceResourceName, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/applications/{applicationResourceName}/services/{serviceResourceName}/replicas", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServiceReplicaClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServiceReplicaClient) ListResponder(resp *http.Response) (result ServiceReplicaDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ServiceReplicaClient) listNextResults(ctx context.Context, lastResults ServiceReplicaDescriptionList) (result ServiceReplicaDescriptionList, err error) { + req, err := lastResults.serviceReplicaDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.ServiceReplicaClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.ServiceReplicaClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.ServiceReplicaClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServiceReplicaClient) ListComplete(ctx context.Context, resourceGroupName string, applicationResourceName string, serviceResourceName string) (result ServiceReplicaDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServiceReplicaClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, applicationResourceName, serviceResourceName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/version.go new file mode 100644 index 000000000000..5b6fff24e3a1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/version.go @@ -0,0 +1,30 @@ +package servicefabricmesh + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " servicefabricmesh/2018-09-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/volume.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/volume.go new file mode 100644 index 000000000000..3f4e5cafc7c1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh/volume.go @@ -0,0 +1,510 @@ +package servicefabricmesh + +// 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" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// VolumeClient is the service Fabric Mesh Management Client +type VolumeClient struct { + BaseClient +} + +// NewVolumeClient creates an instance of the VolumeClient client. +func NewVolumeClient(subscriptionID string) VolumeClient { + return NewVolumeClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVolumeClientWithBaseURI creates an instance of the VolumeClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewVolumeClientWithBaseURI(baseURI string, subscriptionID string) VolumeClient { + return VolumeClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a volume resource with the specified name, description and properties. If a volume resource with the +// same name exists, then it is updated with the specified description and properties. +// Parameters: +// resourceGroupName - azure resource group name +// volumeResourceName - the identity of the volume. +// volumeResourceDescription - description for creating a Volume resource. +func (client VolumeClient) Create(ctx context.Context, resourceGroupName string, volumeResourceName string, volumeResourceDescription VolumeResourceDescription) (result VolumeResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: volumeResourceDescription, + Constraints: []validation.Constraint{{Target: "volumeResourceDescription.VolumeResourceProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "volumeResourceDescription.VolumeResourceProperties.Provider", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "volumeResourceDescription.VolumeResourceProperties.AzureFileParameters", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "volumeResourceDescription.VolumeResourceProperties.AzureFileParameters.AccountName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "volumeResourceDescription.VolumeResourceProperties.AzureFileParameters.ShareName", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("servicefabricmesh.VolumeClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, volumeResourceName, volumeResourceDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client VolumeClient) CreatePreparer(ctx context.Context, resourceGroupName string, volumeResourceName string, volumeResourceDescription VolumeResourceDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeResourceName": volumeResourceName, + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/volumes/{volumeResourceName}", pathParameters), + autorest.WithJSON(volumeResourceDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client VolumeClient) CreateResponder(resp *http.Response) (result VolumeResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the volume resource identified by the name. +// Parameters: +// resourceGroupName - azure resource group name +// volumeResourceName - the identity of the volume. +func (client VolumeClient) Delete(ctx context.Context, resourceGroupName string, volumeResourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, volumeResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client VolumeClient) DeletePreparer(ctx context.Context, resourceGroupName string, volumeResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeResourceName": volumeResourceName, + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/volumes/{volumeResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VolumeClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the information about the volume resource with the given name. The information include the description and +// other properties of the volume. +// Parameters: +// resourceGroupName - azure resource group name +// volumeResourceName - the identity of the volume. +func (client VolumeClient) Get(ctx context.Context, resourceGroupName string, volumeResourceName string) (result VolumeResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, volumeResourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VolumeClient) GetPreparer(ctx context.Context, resourceGroupName string, volumeResourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "volumeResourceName": volumeResourceName, + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/volumes/{volumeResourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VolumeClient) GetResponder(resp *http.Response) (result VolumeResourceDescription, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup gets the information about all volume resources in a given resource group. The information +// include the description and other properties of the Volume. +// Parameters: +// resourceGroupName - azure resource group name +func (client VolumeClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result VolumeResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.vrdl.Response.Response != nil { + sc = result.vrdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.vrdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.vrdl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client VolumeClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabricMesh/volumes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client VolumeClient) ListByResourceGroupResponder(resp *http.Response) (result VolumeResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client VolumeClient) listByResourceGroupNextResults(ctx context.Context, lastResults VolumeResourceDescriptionList) (result VolumeResourceDescriptionList, err error) { + req, err := lastResults.volumeResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client VolumeClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result VolumeResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription gets the information about all volume resources in a given resource group. The information +// include the description and other properties of the volume. +func (client VolumeClient) ListBySubscription(ctx context.Context) (result VolumeResourceDescriptionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeClient.ListBySubscription") + defer func() { + sc := -1 + if result.vrdl.Response.Response != nil { + sc = result.vrdl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.vrdl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.vrdl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client VolumeClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabricMesh/volumes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client VolumeClient) ListBySubscriptionResponder(resp *http.Response) (result VolumeResourceDescriptionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client VolumeClient) listBySubscriptionNextResults(ctx context.Context, lastResults VolumeResourceDescriptionList) (result VolumeResourceDescriptionList, err error) { + req, err := lastResults.volumeResourceDescriptionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabricmesh.VolumeClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client VolumeClient) ListBySubscriptionComplete(ctx context.Context) (result VolumeResourceDescriptionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/VolumeClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 06ff64d2f3ed..ce3c18ffb7a0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -70,6 +70,7 @@ github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-03-01-pre github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v1.0/security github.com/Azure/azure-sdk-for-go/services/preview/securityinsight/mgmt/2017-08-01-preview/securityinsight github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2018-01-01-preview/servicebus +github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v3.0/sql github.com/Azure/azure-sdk-for-go/services/preview/sqlvirtualmachine/mgmt/2017-03-01-preview/sqlvirtualmachine From 7b67d5d4590f47d91fb27744bfdacc603f8dbd94 Mon Sep 17 00:00:00 2001 From: Matthew Frahry Date: Mon, 4 May 2020 17:25:47 -0700 Subject: [PATCH 03/14] More fields --- ...rce_arm_service_fabric_mesh_application.go | 58 ++++++++++++++++++- ...rm_service_fabric_mesh_application_test.go | 7 ++- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go b/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go index f8b83c5e0686..ae2b0e41fc4d 100644 --- a/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go +++ b/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go @@ -63,13 +63,26 @@ func resourceArmServiceFabricMeshApplication() *schema.Resource { ValidateFunc: validate.NoEmptyStrings, }, "os_type": { - Type: schema.TypeString, + Type: schema.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ string(servicefabricmesh.Linux), string(servicefabricmesh.Windows), }, false), }, + "code_package": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.NoEmptyStrings, + }, + }, + }, + }, }, }, }, @@ -183,7 +196,7 @@ func resourceArmServiceFabricMeshApplicationDelete(d *schema.ResourceData, meta } func expandServiceFabricMeshApplicationServices(input []interface{}) *[]servicefabricmesh.ServiceResourceDescription { - services := make([]servicefabricmesh.ServiceResourceDescription, 0, len(input)) + services := make([]servicefabricmesh.ServiceResourceDescription, 0) for _, serviceConfig := range input { if serviceConfig == nil { @@ -193,12 +206,33 @@ func expandServiceFabricMeshApplicationServices(input []interface{}) *[]servicef services = append(services, servicefabricmesh.ServiceResourceDescription{ Name: utils.String(config["name"].(string)), + ServiceResourceProperties: &servicefabricmesh.ServiceResourceProperties{ + OsType: servicefabricmesh.OperatingSystemType(config["os_type"].(string)), + CodePackages: expandServiceFabricMeshCodePackages(config["code_package"].(*schema.Set).List()), + }, }) } return &services } +func expandServiceFabricMeshCodePackages(input []interface{}) *[]servicefabricmesh.ContainerCodePackageProperties { + codePackages := make([]servicefabricmesh.ContainerCodePackageProperties, 0, len(input)) + + for _, codePackageConfig := range input { + if codePackageConfig == nil { + continue + } + config := codePackageConfig.(map[string]interface{}) + + codePackages = append(codePackages, servicefabricmesh.ContainerCodePackageProperties{ + Name: utils.String(config["name"].(string)), + }) + } + + return &codePackages +} + func flattenServiceFabricMeshApplicationServices(input *[]servicefabricmesh.ServiceResourceDescription) []map[string]interface{} { result := make([]map[string]interface{}, 0) if input == nil { @@ -211,8 +245,28 @@ func flattenServiceFabricMeshApplicationServices(input *[]servicefabricmesh.Serv attr["name"] = *service.Name } + attr["os_type"] = string(service.OsType) + + attr["code_package"] = flattenServiceFabricMeshApplicationCodePackage(service.CodePackages) + result = append(result, attr) } return result } + +func flattenServiceFabricMeshApplicationCodePackage(input *[]servicefabricmesh.ContainerCodePackageProperties) []map[string]interface{} { + result := make([]map[string]interface{}, 0) + if input == nil { + return result + } + + for _, codePackage := range *input { + attr := make(map[string]interface{}, 0) + if codePackage.Name != nil { + attr["name"] = *codePackage.Name + } + } + + return result +} diff --git a/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go b/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go index 48222f4ffbe0..ed9ed91bfbb4 100644 --- a/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go +++ b/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go @@ -105,7 +105,12 @@ resource "azurerm_service_fabric_mesh_application" "test" { location = azurerm_resource_group.test.location service { - name = "testservice1" + name = "testservice1" + os_type = "Linux" + + code_package { + name = "testcodepackage1" + } } } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) From 3eef64de3aedf97534c0162db65ae7d8fceb9166 Mon Sep 17 00:00:00 2001 From: Matthew Frahry Date: Tue, 5 May 2020 15:51:00 -0700 Subject: [PATCH 04/14] Basic test + docs --- ...rce_arm_service_fabric_mesh_application.go | 200 ++++++++++++++++-- ...rm_service_fabric_mesh_application_test.go | 14 +- website/allowed-subcategories | 1 + website/azurerm.erb | 9 + ...vice_fabric_mesh_application.html.markdown | 126 +++++++++++ 5 files changed, 328 insertions(+), 22 deletions(-) create mode 100644 website/docs/r/service_fabric_mesh_application.html.markdown diff --git a/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go b/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go index ae2b0e41fc4d..ec5f0d5e0948 100644 --- a/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go +++ b/azurerm/internal/services/servicefabricmesh/resource_arm_service_fabric_mesh_application.go @@ -1,21 +1,22 @@ package servicefabricmesh import ( + "context" "fmt" - "github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/validate" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabricmesh/parse" "log" "time" + "github.com/Azure/azure-sdk-for-go/services/preview/servicefabricmesh/mgmt/2018-09-01-preview/servicefabricmesh" "github.com/hashicorp/go-azure-helpers/response" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicefabricmesh/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" @@ -45,10 +46,10 @@ func resourceArmServiceFabricMeshApplication() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.NoEmptyStrings, + ValidateFunc: validation.StringIsNotEmpty, }, - "resource_group_name": azure.SchemaResourceGroupName(), + "resource_group_name": azure.SchemaResourceGroupNameDiffSuppress(), "location": azure.SchemaLocation(), @@ -60,7 +61,7 @@ func resourceArmServiceFabricMeshApplication() *schema.Resource { "name": { Type: schema.TypeString, Required: true, - ValidateFunc: validate.NoEmptyStrings, + ValidateFunc: validation.StringIsNotEmpty, }, "os_type": { Type: schema.TypeString, @@ -78,7 +79,59 @@ func resourceArmServiceFabricMeshApplication() *schema.Resource { "name": { Type: schema.TypeString, Required: true, - ValidateFunc: validate.NoEmptyStrings, + ValidateFunc: validation.StringIsNotEmpty, + }, + "image_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + "resources": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "requests": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "memory": { + Type: schema.TypeFloat, + Required: true, + ValidateFunc: validation.FloatAtLeast(0), + }, + "cpu": { + Type: schema.TypeFloat, + Required: true, + ValidateFunc: validation.FloatAtLeast(0), + }, + }, + }, + }, + "limits": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "memory": { + Type: schema.TypeFloat, + Required: true, + ValidateFunc: validation.FloatAtLeast(0), + }, + "cpu": { + Type: schema.TypeFloat, + Required: true, + ValidateFunc: validation.FloatAtLeast(0), + }, + }, + }, + }, + }, + }, }, }, }, @@ -87,12 +140,6 @@ func resourceArmServiceFabricMeshApplication() *schema.Resource { }, }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.NoEmptyStrings, - }, - "tags": tags.Schema(), }, } @@ -123,7 +170,6 @@ func resourceArmServiceFabricMeshApplicationCreateUpdate(d *schema.ResourceData, parameters := servicefabricmesh.ApplicationResourceDescription{ ApplicationResourceProperties: &servicefabricmesh.ApplicationResourceProperties{ - Description: utils.String(d.Get("description").(string)), Services: expandServiceFabricMeshApplicationServices(d.Get("service").(*schema.Set).List()), }, Location: utils.String(location), @@ -134,6 +180,20 @@ func resourceArmServiceFabricMeshApplicationCreateUpdate(d *schema.ResourceData, return fmt.Errorf("creating Service Fabric Mesh Application %q (Resource Group %q): %+v", name, resourceGroup, err) } + log.Printf("[DEBUG] Waiting for Service Fabric Mesh Application %q (Resource Group %q) to finish creating", name, resourceGroup) + stateConf := &resource.StateChangeConf{ + Pending: []string{string(servicefabricmesh.Creating)}, + Target: []string{string(servicefabricmesh.Ready)}, + Refresh: serviceFabricMeshApplicationCreateRefreshFunc(ctx, client, resourceGroup, name), + MinTimeout: 10 * time.Second, + ContinuousTargetOccurence: 10, + Timeout: d.Timeout(schema.TimeoutCreate), + } + + if _, err := stateConf.WaitForState(); err != nil { + return fmt.Errorf("waiting for Service Fabric Mesh Application %q (Resource Group %q) to become available: %+v", name, resourceGroup, err) + } + resp, err := client.Get(ctx, resourceGroup, name) if err != nil { return fmt.Errorf("retrieving Service Fabric Mesh Application %q (Resource Group %q): %+v", name, resourceGroup, err) @@ -169,9 +229,10 @@ func resourceArmServiceFabricMeshApplicationRead(d *schema.ResourceData, meta in d.Set("resource_group_name", id.ResourceGroup) d.Set("location", location.NormalizeNilable(resp.Location)) + /* This does not currently return from the api if err := d.Set("service", flattenServiceFabricMeshApplicationServices(resp.Services)); err != nil { return fmt.Errorf("setting `service`: %+v", err) - } + }*/ return tags.FlattenAndSet(d, resp.Tags) } @@ -226,13 +287,51 @@ func expandServiceFabricMeshCodePackages(input []interface{}) *[]servicefabricme config := codePackageConfig.(map[string]interface{}) codePackages = append(codePackages, servicefabricmesh.ContainerCodePackageProperties{ - Name: utils.String(config["name"].(string)), + Name: utils.String(config["name"].(string)), + Image: utils.String(config["image_name"].(string)), + Resources: expandServiceFabricMeshCodePackageResources(config["resources"].([]interface{})), }) } return &codePackages } +func expandServiceFabricMeshCodePackageResources(input []interface{}) *servicefabricmesh.ResourceRequirements { + if len(input) == 0 || input[0] == nil { + return nil + } + attr := input[0].(map[string]interface{}) + + return &servicefabricmesh.ResourceRequirements{ + Limits: expandServiceFabricMeshCodePackageResourceLimits(attr["limits"].([]interface{})), + Requests: expandServiceFabricMeshCodePackageResourceRequests(attr["requests"].([]interface{})), + } +} + +func expandServiceFabricMeshCodePackageResourceLimits(input []interface{}) *servicefabricmesh.ResourceLimits { + if len(input) == 0 || input[0] == nil { + return nil + } + attr := input[0].(map[string]interface{}) + + return &servicefabricmesh.ResourceLimits{ + MemoryInGB: utils.Float(attr["memory"].(float64)), + CPU: utils.Float(attr["cpu"].(float64)), + } +} + +func expandServiceFabricMeshCodePackageResourceRequests(input []interface{}) *servicefabricmesh.ResourceRequests { + if len(input) == 0 || input[0] == nil { + return nil + } + attr := input[0].(map[string]interface{}) + + return &servicefabricmesh.ResourceRequests{ + MemoryInGB: utils.Float(attr["memory"].(float64)), + CPU: utils.Float(attr["cpu"].(float64)), + } +} + func flattenServiceFabricMeshApplicationServices(input *[]servicefabricmesh.ServiceResourceDescription) []map[string]interface{} { result := make([]map[string]interface{}, 0) if input == nil { @@ -244,9 +343,7 @@ func flattenServiceFabricMeshApplicationServices(input *[]servicefabricmesh.Serv if service.Name != nil { attr["name"] = *service.Name } - attr["os_type"] = string(service.OsType) - attr["code_package"] = flattenServiceFabricMeshApplicationCodePackage(service.CodePackages) result = append(result, attr) @@ -266,7 +363,72 @@ func flattenServiceFabricMeshApplicationCodePackage(input *[]servicefabricmesh.C if codePackage.Name != nil { attr["name"] = *codePackage.Name } + if codePackage.Image != nil { + attr["image_name"] = *codePackage.Image + } + attr["resources"] = flattenServiceFabricMeshApplicationCodePackageResources(codePackage.Resources) + + result = append(result, attr) } return result } + +func flattenServiceFabricMeshApplicationCodePackageResources(input *servicefabricmesh.ResourceRequirements) []map[string]interface{} { + result := make([]map[string]interface{}, 0) + if input == nil { + return result + } + attr := make(map[string]interface{}, 0) + attr["requests"] = flattenServiceFabricMeshApplicationCodePackageResourceRequests(input.Requests) + attr["limits"] = flattenServiceFabricMeshApplicationCodePackageResourceLimits(input.Limits) + + result = append(result, attr) + + return result +} + +func flattenServiceFabricMeshApplicationCodePackageResourceRequests(input *servicefabricmesh.ResourceRequests) []map[string]interface{} { + result := make([]map[string]interface{}, 0) + if input == nil { + return result + } + attr := make(map[string]interface{}, 0) + if input.MemoryInGB != nil { + attr["memory"] = *input.MemoryInGB + } + if input.CPU != nil { + attr["cpu"] = *input.CPU + } + result = append(result, attr) + + return result +} + +func flattenServiceFabricMeshApplicationCodePackageResourceLimits(input *servicefabricmesh.ResourceLimits) []map[string]interface{} { + result := make([]map[string]interface{}, 0) + if input == nil { + return result + } + attr := make(map[string]interface{}, 0) + if input.MemoryInGB != nil { + attr["memory"] = *input.MemoryInGB + } + if input.CPU != nil { + attr["cpu"] = *input.CPU + } + result = append(result, attr) + + return result +} + +func serviceFabricMeshApplicationCreateRefreshFunc(ctx context.Context, client *servicefabricmesh.ApplicationClient, resourceGroup string, name string) resource.StateRefreshFunc { + return func() (interface{}, string, error) { + res, err := client.Get(ctx, resourceGroup, name) + if err != nil { + return nil, "Error", fmt.Errorf("issuing read request in serviceFabricMeshApplicationCreateRefreshFunc %q (Resource Group %q): %s", name, resourceGroup, err) + } + + return res, string(res.Status), nil + } +} diff --git a/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go b/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go index ed9ed91bfbb4..3206718adda6 100644 --- a/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go +++ b/azurerm/internal/services/servicefabricmesh/tests/resource_arm_service_fabric_mesh_application_test.go @@ -13,7 +13,7 @@ import ( ) func TestAccAzureRMServiceFabricMeshApplication_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_service_fabric_mesh_application_test", "test") + data := acceptance.BuildTestData(t, "azurerm_service_fabric_mesh_application", "test") resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acceptance.PreCheck(t) }, @@ -26,7 +26,7 @@ func TestAccAzureRMServiceFabricMeshApplication_basic(t *testing.T) { testCheckAzureRMServiceFabricMeshApplicationExists(data.ResourceName), ), }, - data.ImportStep(), + data.ImportStep("service"), }, }) } @@ -109,7 +109,15 @@ resource "azurerm_service_fabric_mesh_application" "test" { os_type = "Linux" code_package { - name = "testcodepackage1" + name = "testcodepackage1" + image_name = "seabreeze/sbz-helloworld:1.0-alpine" + + resources { + requests { + memory = 1 + cpu = 1 + } + } } } } diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 2b5cf6a9b9e4..40f32bb76968 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -53,6 +53,7 @@ Search Security Center Sentinel Service Fabric +Service Fabric Mesh Spring Cloud Storage Stream Analytics diff --git a/website/azurerm.erb b/website/azurerm.erb index 4e6139df56be..59485dd8cd5e 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -2273,6 +2273,15 @@ +
  • + Service Fabric Mesh Resources + +
  • +
  • Site Recovery Resources