From 5e8bad9555dedada71af47c4defac3d52b6b0502 Mon Sep 17 00:00:00 2001 From: Tilen Faganel Date: Thu, 19 Jul 2018 17:15:44 +0100 Subject: [PATCH 01/95] Added missing advanced schedule properties to the `azurerm_automation_schedule` resource --- azurerm/resource_arm_automation_schedule.go | 175 ++++++++++++++++- .../resource_arm_automation_schedule_test.go | 183 +++++++++++++++++- 2 files changed, 352 insertions(+), 6 deletions(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 2c6a6b0f6024e..ee3e156fbe2cc 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -11,6 +11,7 @@ import ( "github.com/Azure/go-autorest/autorest/date" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/set" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" @@ -107,14 +108,78 @@ func resourceArmAutomationSchedule() *schema.Resource { //todo figure out how to validate this properly }, - //todo missing properties: week_days, month_days, month_week_day from advanced automation section + "advanced_schedule": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "week_days": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validateScheduleDay(), + }, + Set: set.HashStringIgnoreCase, + }, + "month_days": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + ValidateFunc: validate.IntBetweenAndNot(-1, 31, 0), + }, + Set: set.HashInt, + }, + + "monthly_occurrence": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "day": { + Type: schema.TypeString, + Required: true, + DiffSuppressFunc: suppress.CaseDifference, + ValidateFunc: validateScheduleDay(), + }, + "occurrence": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntBetween(1, 5), + }, + }, + }, + }, + }, + }, + }, }, CustomizeDiff: func(diff *schema.ResourceDiff, v interface{}) error { + frequency := strings.ToLower(diff.Get("frequency").(string)) interval, _ := diff.GetOk("interval") - if strings.ToLower(diff.Get("frequency").(string)) == "onetime" && interval.(int) > 0 { - return fmt.Errorf("interval canot be set when frequency is not OneTime") + if frequency == "onetime" && interval.(int) > 0 { + return fmt.Errorf("`interval` cannot be set when frequency is not OneTime") + } + + advancedSchedules, hasAdvancedSchedule := diff.GetOk("advanced_schedule") + if hasAdvancedSchedule { + if asl := advancedSchedules.([]interface{}); len(asl) > 0 && asl[0] != nil { + if frequency != "week" && frequency != "month" { + return fmt.Errorf("`advanced_schedule` can only be set when frequency is `Week` or `Month`") + } + + as := asl[0].(map[string]interface{}) + if frequency == "week" && as["week_days"].(*schema.Set).Len() == 0 { + return fmt.Errorf("`week_days` must be set when frequency is `Week`") + } + if frequency == "month" && as["month_days"].(*schema.Set).Len() == 0 && len(as["monthly_occurrence"].([]interface{})) == 0 { + return fmt.Errorf("Either `month_days` or `monthly_occurrence` must be set when frequency is `Month`") + } + } } _, hasAccount := diff.GetOk("automation_account_name") @@ -193,6 +258,20 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte properties.Interval = 1 } } + + //only pay attention to the advanced schedule if frequency is either Week or Month + if properties.Frequency == automation.Week || properties.Frequency == automation.Month { + if v, ok := d.GetOk("advanced_schedule"); ok { + if vl := v.([]interface{}); len(vl) > 0 && vl[0] != nil { + advancedRef, err := expandArmAutomationScheduleAdvanced(vl) + if err != nil { + return err + } + properties.AdvancedSchedule = advancedRef + } + } + } + _, err := client.CreateOrUpdate(ctx, resGroup, accountName, name, parameters) if err != nil { return err @@ -257,6 +336,9 @@ func resourceArmAutomationScheduleRead(d *schema.ResourceData, meta interface{}) if v := resp.TimeZone; v != nil { d.Set("timezone", v) } + if v := resp.AdvancedSchedule; v != nil { + d.Set("advanced_schedule", flattenArmAutomationScheduleAdvanced(v)) + } return nil } @@ -282,3 +364,90 @@ func resourceArmAutomationScheduleDelete(d *schema.ResourceData, meta interface{ return nil } + +func expandArmAutomationScheduleAdvanced(v []interface{}) (*automation.AdvancedSchedule, error) { + + // Get the one and only advance schedule configuration + advancedSchedule := v[0].(map[string]interface{}) + weekDays := advancedSchedule["week_days"].(*schema.Set).List() + monthDays := advancedSchedule["month_days"].(*schema.Set).List() + monthlyOccurrences := advancedSchedule["monthly_occurrence"].([]interface{}) + + expandedAdvancedSchedule := automation.AdvancedSchedule{} + + if len(weekDays) > 0 { + expandedWeekDays := make([]string, len(weekDays)) + for i := range weekDays { + expandedWeekDays[i] = weekDays[i].(string) + } + expandedAdvancedSchedule.WeekDays = &expandedWeekDays + } + + if len(monthDays) > 0 { + expandedMonthDays := make([]int32, len(monthDays)) + for i := range monthDays { + expandedMonthDays[i] = int32(monthDays[i].(int)) + } + expandedAdvancedSchedule.MonthDays = &expandedMonthDays + } + + if len(monthlyOccurrences) > 0 { + expandedMonthlyOccurrences := make([]automation.AdvancedScheduleMonthlyOccurrence, len(monthlyOccurrences)) + for i := range monthlyOccurrences { + m := monthlyOccurrences[i].(map[string]interface{}) + occurrence := int32(m["occurrence"].(int)) + + expandedMonthlyOccurrences[i] = automation.AdvancedScheduleMonthlyOccurrence{ + Occurrence: &occurrence, + Day: automation.ScheduleDay(m["day"].(string)), + } + } + expandedAdvancedSchedule.MonthlyOccurrences = &expandedMonthlyOccurrences + } + + return &expandedAdvancedSchedule, nil +} + +func flattenArmAutomationScheduleAdvanced(v *automation.AdvancedSchedule) []interface{} { + result := make(map[string]interface{}) + + if v.WeekDays != nil { + flattenedWeekDays := schema.NewSet(set.HashStringIgnoreCase, []interface{}{}) + for i := range *v.WeekDays { + flattenedWeekDays.Add((*v.WeekDays)[i]) + } + result["week_days"] = flattenedWeekDays + } + if v.MonthDays != nil { + flattenedMonthDays := schema.NewSet(set.HashInt, []interface{}{}) + for i := range *v.MonthDays { + flattenedMonthDays.Add(int(((*v.MonthDays)[i]))) + } + result["month_days"] = flattenedMonthDays + } + if v.MonthlyOccurrences != nil { + flattenedMonthlyOccurrences := make([]map[string]interface{}, len(*v.MonthlyOccurrences)) + for i := range *v.MonthlyOccurrences { + f := make(map[string]interface{}) + f["day"] = (*v.MonthlyOccurrences)[i].Day + f["occurrence"] = int(*(*v.MonthlyOccurrences)[i].Occurrence) + flattenedMonthlyOccurrences[i] = f + } + result["monthly_occurrence"] = flattenedMonthlyOccurrences + } + + return []interface{}{result} +} + +func validateScheduleDay() schema.SchemaValidateFunc { + + return validation.StringInSlice([]string{ + string(automation.Monday), + string(automation.Tuesday), + string(automation.Wednesday), + string(automation.Thursday), + string(automation.Friday), + string(automation.Saturday), + string(automation.Sunday), + }, true) +} diff --git a/azurerm/resource_arm_automation_schedule_test.go b/azurerm/resource_arm_automation_schedule_test.go index 74479f97d8e19..2a887f207ba71 100644 --- a/azurerm/resource_arm_automation_schedule_test.go +++ b/azurerm/resource_arm_automation_schedule_test.go @@ -2,13 +2,14 @@ package azurerm import ( "fmt" + "strconv" + "testing" + "time" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" - "strconv" - "testing" - "time" ) func TestAccAzureRMAutomationSchedule_oneTime_basic(t *testing.T) { @@ -174,6 +175,72 @@ func TestAccAzureRMAutomationSchedule_monthly(t *testing.T) { }) } +func TestAccAzureRMAutomationSchedule_weekly_advanced(t *testing.T) { + resourceName := "azurerm_automation_schedule.test" + ri := acctest.RandInt() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationScheduleDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMAutomationSchedule_recurring_advanced_week(ri, testLocation(), "Week", 1, "Monday"), + Check: checkAccAzureRMAutomationSchedule_recurring_advanced_week(resourceName, "Week", 1, "Monday"), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAutomationSchedule_monthly_advanced_by_day(t *testing.T) { + resourceName := "azurerm_automation_schedule.test" + ri := acctest.RandInt() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationScheduleDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMAutomationSchedule_recurring_advanced_month(ri, testLocation(), "Month", 1, 2), + Check: checkAccAzureRMAutomationSchedule_recurring_advanced_month(resourceName, "Month", 1, 2), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAutomationSchedule_monthly_advanced_by_week_day(t *testing.T) { + resourceName := "azurerm_automation_schedule.test" + ri := acctest.RandInt() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAutomationScheduleDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMAutomationSchedule_recurring_advanced_month_week_day(ri, testLocation(), "Month", 1, "Monday", 2), + Check: checkAccAzureRMAutomationSchedule_recurring_advanced_month_week_day(resourceName, "Month", 1, "Monday", 2), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testCheckAzureRMAutomationScheduleDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*ArmClient).automationScheduleClient ctx := testAccProvider.Meta().(*ArmClient).StopContext @@ -338,3 +405,113 @@ func checkAccAzureRMAutomationSchedule_recurring_basic(resourceName string, freq resource.TestCheckResourceAttr(resourceName, "timezone", "UTC"), ) } + +func testAccAzureRMAutomationSchedule_recurring_advanced_week(rInt int, location, frequency string, interval int, weekDay string) string { + return fmt.Sprintf(` +%s + +resource "azurerm_automation_schedule" "test" { + name = "acctestAS-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + automation_account_name = "${azurerm_automation_account.test.name}" + frequency = "%s" + interval = "%d" + + advanced_schedule { + week_days = ["%s"] + } +} +`, testAccAzureRMAutomationSchedule_prerequisites(rInt, location), rInt, frequency, interval, weekDay) +} + +func checkAccAzureRMAutomationSchedule_recurring_advanced_week(resourceName string, frequency string, interval int, weekDay string) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + testCheckAzureRMAutomationScheduleExists("azurerm_automation_schedule.test"), + resource.TestCheckResourceAttrSet(resourceName, "name"), + resource.TestCheckResourceAttrSet(resourceName, "resource_group_name"), + resource.TestCheckResourceAttrSet(resourceName, "automation_account_name"), + resource.TestCheckResourceAttrSet(resourceName, "start_time"), + resource.TestCheckResourceAttr(resourceName, "frequency", frequency), + resource.TestCheckResourceAttr(resourceName, "interval", strconv.Itoa(interval)), + resource.TestCheckResourceAttr(resourceName, "timezone", "UTC"), + resource.TestCheckResourceAttr(resourceName, "advanced_schedule.#", "1"), + resource.TestCheckResourceAttr(resourceName, "advanced_schedule.0.week_days.#", "1"), + ) +} + +func testAccAzureRMAutomationSchedule_recurring_advanced_month(rInt int, location, frequency string, interval int, monthDay int) string { + return fmt.Sprintf(` +%s + +resource "azurerm_automation_schedule" "test" { + name = "acctestAS-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + automation_account_name = "${azurerm_automation_account.test.name}" + frequency = "%s" + interval = "%d" + + advanced_schedule { + month_days = [%d] + } +} +`, testAccAzureRMAutomationSchedule_prerequisites(rInt, location), rInt, frequency, interval, monthDay) +} + +func checkAccAzureRMAutomationSchedule_recurring_advanced_month(resourceName string, frequency string, interval int, monthDay int) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + testCheckAzureRMAutomationScheduleExists("azurerm_automation_schedule.test"), + resource.TestCheckResourceAttrSet(resourceName, "name"), + resource.TestCheckResourceAttrSet(resourceName, "resource_group_name"), + resource.TestCheckResourceAttrSet(resourceName, "automation_account_name"), + resource.TestCheckResourceAttrSet(resourceName, "start_time"), + resource.TestCheckResourceAttr(resourceName, "frequency", frequency), + resource.TestCheckResourceAttr(resourceName, "interval", strconv.Itoa(interval)), + resource.TestCheckResourceAttr(resourceName, "timezone", "UTC"), + resource.TestCheckResourceAttr(resourceName, "advanced_schedule.#", "1"), + resource.TestCheckResourceAttr(resourceName, "advanced_schedule.0.month_days.#", "1"), + ) +} + +func testAccAzureRMAutomationSchedule_recurring_advanced_month_week_day(rInt int, location, frequency string, interval int, + weekDay string, weekDayOccurrence int) string { + + return fmt.Sprintf(` +%s + +resource "azurerm_automation_schedule" "test" { + name = "acctestAS-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + automation_account_name = "${azurerm_automation_account.test.name}" + frequency = "%s" + interval = "%d" + + advanced_schedule { + + monthly_occurrence { + day = "%s" + occurrence = "%d" + } + } +} +`, testAccAzureRMAutomationSchedule_prerequisites(rInt, location), rInt, frequency, interval, weekDay, weekDayOccurrence) +} + +func checkAccAzureRMAutomationSchedule_recurring_advanced_month_week_day(resourceName string, frequency string, interval int, + monthWeekDay string, monthWeekOccurrence int) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + testCheckAzureRMAutomationScheduleExists("azurerm_automation_schedule.test"), + resource.TestCheckResourceAttrSet(resourceName, "name"), + resource.TestCheckResourceAttrSet(resourceName, "resource_group_name"), + resource.TestCheckResourceAttrSet(resourceName, "automation_account_name"), + resource.TestCheckResourceAttrSet(resourceName, "start_time"), + resource.TestCheckResourceAttr(resourceName, "frequency", frequency), + resource.TestCheckResourceAttr(resourceName, "interval", strconv.Itoa(interval)), + resource.TestCheckResourceAttr(resourceName, "timezone", "UTC"), + resource.TestCheckResourceAttrSet(resourceName, "advanced_schedule.0.monthly_occurrence.0.day"), + resource.TestCheckResourceAttrSet(resourceName, "advanced_schedule.0.monthly_occurrence.0.occurrence"), + resource.TestCheckResourceAttr(resourceName, "advanced_schedule.#", "1"), + resource.TestCheckResourceAttr(resourceName, "advanced_schedule.0.monthly_occurrence.#", "1"), + resource.TestCheckResourceAttr(resourceName, "advanced_schedule.0.monthly_occurrence.0.day", monthWeekDay), + resource.TestCheckResourceAttr(resourceName, "advanced_schedule.0.monthly_occurrence.0.occurrence", strconv.Itoa(monthWeekOccurrence)), + ) +} From ab3ca155c6f5264befc7a4ad438c65376d912c63 Mon Sep 17 00:00:00 2001 From: Tilen Faganel Date: Sun, 22 Jul 2018 22:55:14 +0100 Subject: [PATCH 02/95] Added webside docs for the missing advanced schedule properties in the `azurerm_automation_schedule` resource --- .../docs/r/automation_schedule.html.markdown | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/website/docs/r/automation_schedule.html.markdown b/website/docs/r/automation_schedule.html.markdown index 0d0180ecaf1a0..e7ccee290b2a1 100644 --- a/website/docs/r/automation_schedule.html.markdown +++ b/website/docs/r/automation_schedule.html.markdown @@ -31,11 +31,15 @@ resource "azurerm_automation_schedule" "example" { name = "tfex-automation-schedule" resource_group_name = "${azurerm_resource_group.example.name}" automation_account_name = "${azurerm_automation_account.example.name}" - frequency = "Hour" + frequency = "Week" interval = 1 timezone = "Central Europe Standard Time" start_time = "2014-04-15T18:00:15+02:00" description = "This is an example schedule" + + advanced_schedule { + week_days = ["Friday"] + } } ``` @@ -61,6 +65,22 @@ The following arguments are supported: * `timezone` - (Optional) The timezone of the start time. Defaults to `UTC`. For possible values see: https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx +* `advanced_schedule` - (Optional) Advanced fine-grained schedule frequency configuration. The `advanced_schedule` block supports fields documented below. + +The `advanced_schedule` block supports: + +* `week_days` - (Optional) List of days of the week that the job should execute on. + +* `month_days` - (Optional) List of days of the month that the job should execute on. Must be between 1 and 31. 0 for last day of the month. + +* `monthly_occurrence` - (Optional) List of occurrences of days within a month. The `monthly_occurrence` block supports fields documented below. + +The `monthly_occurrence` block supports: + +* `day` - (Required) Day of the occurrence. Must be one of Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. + +* `occurrence` - (Required) Occurrence of the week within the month. Must be between 1 and 5. + ## Attributes Reference The following attributes are exported: From adab6826d55fd0124018a812508ab5fc0f3ec588 Mon Sep 17 00:00:00 2001 From: Tilen Faganel Date: Mon, 23 Jul 2018 14:06:33 +0100 Subject: [PATCH 03/95] Minor fixes to the code quality and diff behavior with the advanced properties of the `azurerm_automation_schedule` resource --- azurerm/resource_arm_automation_schedule.go | 84 +++++++++++-------- .../docs/r/automation_schedule.html.markdown | 4 + 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index ee3e156fbe2cc..59f1ebe3cf334 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -118,8 +118,16 @@ func resourceArmAutomationSchedule() *schema.Resource { Type: schema.TypeSet, Optional: true, Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validateScheduleDay(), + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(automation.Monday), + string(automation.Tuesday), + string(automation.Wednesday), + string(automation.Thursday), + string(automation.Friday), + string(automation.Saturday), + string(automation.Sunday), + }, true), }, Set: set.HashStringIgnoreCase, }, @@ -142,7 +150,15 @@ func resourceArmAutomationSchedule() *schema.Resource { Type: schema.TypeString, Required: true, DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: validateScheduleDay(), + ValidateFunc: validation.StringInSlice([]string{ + string(automation.Monday), + string(automation.Tuesday), + string(automation.Wednesday), + string(automation.Thursday), + string(automation.Friday), + string(automation.Saturday), + string(automation.Sunday), + }, true), }, "occurrence": { Type: schema.TypeInt, @@ -167,7 +183,7 @@ func resourceArmAutomationSchedule() *schema.Resource { advancedSchedules, hasAdvancedSchedule := diff.GetOk("advanced_schedule") if hasAdvancedSchedule { - if asl := advancedSchedules.([]interface{}); len(asl) > 0 && asl[0] != nil { + if asl := advancedSchedules.([]interface{}); len(asl) > 0 { if frequency != "week" && frequency != "month" { return fmt.Errorf("`advanced_schedule` can only be set when frequency is `Week` or `Month`") } @@ -262,7 +278,7 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte //only pay attention to the advanced schedule if frequency is either Week or Month if properties.Frequency == automation.Week || properties.Frequency == automation.Month { if v, ok := d.GetOk("advanced_schedule"); ok { - if vl := v.([]interface{}); len(vl) > 0 && vl[0] != nil { + if vl := v.([]interface{}); len(vl) > 0 { advancedRef, err := expandArmAutomationScheduleAdvanced(vl) if err != nil { return err @@ -336,8 +352,8 @@ func resourceArmAutomationScheduleRead(d *schema.ResourceData, meta interface{}) if v := resp.TimeZone; v != nil { d.Set("timezone", v) } - if v := resp.AdvancedSchedule; v != nil { - d.Set("advanced_schedule", flattenArmAutomationScheduleAdvanced(v)) + if err := d.Set("advanced_schedule", flattenArmAutomationScheduleAdvanced(resp.AdvancedSchedule)); err != nil { + return fmt.Errorf("Error setting `advanced_schedule`: %+v", err) } return nil } @@ -375,6 +391,8 @@ func expandArmAutomationScheduleAdvanced(v []interface{}) (*automation.AdvancedS expandedAdvancedSchedule := automation.AdvancedSchedule{} + // If frequency is set to `Month` the `week_days` array cannot be set (even empty), otherwise the API returns an error. + // Interestingly enough, during update it can be set and it will not return an error. if len(weekDays) > 0 { expandedWeekDays := make([]string, len(weekDays)) for i := range weekDays { @@ -383,6 +401,7 @@ func expandArmAutomationScheduleAdvanced(v []interface{}) (*automation.AdvancedS expandedAdvancedSchedule.WeekDays = &expandedWeekDays } + // Same as above with `week_days` if len(monthDays) > 0 { expandedMonthDays := make([]int32, len(monthDays)) for i := range monthDays { @@ -391,63 +410,54 @@ func expandArmAutomationScheduleAdvanced(v []interface{}) (*automation.AdvancedS expandedAdvancedSchedule.MonthDays = &expandedMonthDays } - if len(monthlyOccurrences) > 0 { - expandedMonthlyOccurrences := make([]automation.AdvancedScheduleMonthlyOccurrence, len(monthlyOccurrences)) - for i := range monthlyOccurrences { - m := monthlyOccurrences[i].(map[string]interface{}) - occurrence := int32(m["occurrence"].(int)) + expandedMonthlyOccurrences := make([]automation.AdvancedScheduleMonthlyOccurrence, len(monthlyOccurrences)) + for i := range monthlyOccurrences { + m := monthlyOccurrences[i].(map[string]interface{}) + occurrence := int32(m["occurrence"].(int)) - expandedMonthlyOccurrences[i] = automation.AdvancedScheduleMonthlyOccurrence{ - Occurrence: &occurrence, - Day: automation.ScheduleDay(m["day"].(string)), - } + expandedMonthlyOccurrences[i] = automation.AdvancedScheduleMonthlyOccurrence{ + Occurrence: &occurrence, + Day: automation.ScheduleDay(m["day"].(string)), } - expandedAdvancedSchedule.MonthlyOccurrences = &expandedMonthlyOccurrences } + expandedAdvancedSchedule.MonthlyOccurrences = &expandedMonthlyOccurrences return &expandedAdvancedSchedule, nil } func flattenArmAutomationScheduleAdvanced(v *automation.AdvancedSchedule) []interface{} { + if v == nil { + return []interface{}{} + } + result := make(map[string]interface{}) + flattenedWeekDays := schema.NewSet(set.HashStringIgnoreCase, []interface{}{}) if v.WeekDays != nil { - flattenedWeekDays := schema.NewSet(set.HashStringIgnoreCase, []interface{}{}) for i := range *v.WeekDays { flattenedWeekDays.Add((*v.WeekDays)[i]) } - result["week_days"] = flattenedWeekDays } + result["week_days"] = flattenedWeekDays + + flattenedMonthDays := schema.NewSet(set.HashInt, []interface{}{}) if v.MonthDays != nil { - flattenedMonthDays := schema.NewSet(set.HashInt, []interface{}{}) for i := range *v.MonthDays { flattenedMonthDays.Add(int(((*v.MonthDays)[i]))) } - result["month_days"] = flattenedMonthDays } + result["month_days"] = flattenedMonthDays + + flattenedMonthlyOccurrences := make([]map[string]interface{}, 0) if v.MonthlyOccurrences != nil { - flattenedMonthlyOccurrences := make([]map[string]interface{}, len(*v.MonthlyOccurrences)) for i := range *v.MonthlyOccurrences { f := make(map[string]interface{}) f["day"] = (*v.MonthlyOccurrences)[i].Day f["occurrence"] = int(*(*v.MonthlyOccurrences)[i].Occurrence) - flattenedMonthlyOccurrences[i] = f + flattenedMonthlyOccurrences = append(flattenedMonthlyOccurrences, f) } - result["monthly_occurrence"] = flattenedMonthlyOccurrences } + result["monthly_occurrence"] = flattenedMonthlyOccurrences return []interface{}{result} } - -func validateScheduleDay() schema.SchemaValidateFunc { - - return validation.StringInSlice([]string{ - string(automation.Monday), - string(automation.Tuesday), - string(automation.Wednesday), - string(automation.Thursday), - string(automation.Friday), - string(automation.Saturday), - string(automation.Sunday), - }, true) -} diff --git a/website/docs/r/automation_schedule.html.markdown b/website/docs/r/automation_schedule.html.markdown index e7ccee290b2a1..623edb3daa300 100644 --- a/website/docs/r/automation_schedule.html.markdown +++ b/website/docs/r/automation_schedule.html.markdown @@ -67,6 +67,8 @@ The following arguments are supported: * `advanced_schedule` - (Optional) Advanced fine-grained schedule frequency configuration. The `advanced_schedule` block supports fields documented below. +--- + The `advanced_schedule` block supports: * `week_days` - (Optional) List of days of the week that the job should execute on. @@ -75,6 +77,8 @@ The `advanced_schedule` block supports: * `monthly_occurrence` - (Optional) List of occurrences of days within a month. The `monthly_occurrence` block supports fields documented below. +--- + The `monthly_occurrence` block supports: * `day` - (Required) Day of the occurrence. Must be one of Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. From 22a9c1c33d73bf066d2e84bee55f5e07c253d6db Mon Sep 17 00:00:00 2001 From: Tilen Faganel Date: Mon, 23 Jul 2018 14:59:02 +0100 Subject: [PATCH 04/95] Updated handling of the advanced properties in the `azurerm_automation_schedule` in case of state change to remove --- azurerm/resource_arm_automation_schedule.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index 59f1ebe3cf334..b06fae20faf86 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -279,12 +279,19 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte if properties.Frequency == automation.Week || properties.Frequency == automation.Month { if v, ok := d.GetOk("advanced_schedule"); ok { if vl := v.([]interface{}); len(vl) > 0 { - advancedRef, err := expandArmAutomationScheduleAdvanced(vl) + advancedRef, err := expandArmAutomationScheduleAdvanced(vl, d.Id() != "") if err != nil { return err } properties.AdvancedSchedule = advancedRef } + } else { + // To make sure all the properties are unset in the event of removal, pass in an empty skeleton object + properties.AdvancedSchedule = &automation.AdvancedSchedule{ + WeekDays: &[]string{}, + MonthDays: &[]int32{}, + MonthlyOccurrences: &[]automation.AdvancedScheduleMonthlyOccurrence{}, + } } } @@ -381,7 +388,7 @@ func resourceArmAutomationScheduleDelete(d *schema.ResourceData, meta interface{ return nil } -func expandArmAutomationScheduleAdvanced(v []interface{}) (*automation.AdvancedSchedule, error) { +func expandArmAutomationScheduleAdvanced(v []interface{}, update bool) (*automation.AdvancedSchedule, error) { // Get the one and only advance schedule configuration advancedSchedule := v[0].(map[string]interface{}) @@ -392,8 +399,8 @@ func expandArmAutomationScheduleAdvanced(v []interface{}) (*automation.AdvancedS expandedAdvancedSchedule := automation.AdvancedSchedule{} // If frequency is set to `Month` the `week_days` array cannot be set (even empty), otherwise the API returns an error. - // Interestingly enough, during update it can be set and it will not return an error. - if len(weekDays) > 0 { + // During update it can be set and it will not return an error. Workaround for the APIs behavior + if len(weekDays) > 0 || update { expandedWeekDays := make([]string, len(weekDays)) for i := range weekDays { expandedWeekDays[i] = weekDays[i].(string) @@ -402,7 +409,7 @@ func expandArmAutomationScheduleAdvanced(v []interface{}) (*automation.AdvancedS } // Same as above with `week_days` - if len(monthDays) > 0 { + if len(monthDays) > 0 || update { expandedMonthDays := make([]int32, len(monthDays)) for i := range monthDays { expandedMonthDays[i] = int32(monthDays[i].(int)) From 980066b22d5f24a483511c7b0a9ea8f4eeeb389c Mon Sep 17 00:00:00 2001 From: Tilen Faganel Date: Tue, 24 Jul 2018 15:03:27 +0100 Subject: [PATCH 05/95] Minor fixes to the handling of the advanced properties on create/update of the `azurerm_automation_schedule` resource --- azurerm/resource_arm_automation_schedule.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/azurerm/resource_arm_automation_schedule.go b/azurerm/resource_arm_automation_schedule.go index b06fae20faf86..f4be7ee7aa2ec 100644 --- a/azurerm/resource_arm_automation_schedule.go +++ b/azurerm/resource_arm_automation_schedule.go @@ -277,16 +277,17 @@ func resourceArmAutomationScheduleCreateUpdate(d *schema.ResourceData, meta inte //only pay attention to the advanced schedule if frequency is either Week or Month if properties.Frequency == automation.Week || properties.Frequency == automation.Month { + isUpdate := d.Id() != "" if v, ok := d.GetOk("advanced_schedule"); ok { if vl := v.([]interface{}); len(vl) > 0 { - advancedRef, err := expandArmAutomationScheduleAdvanced(vl, d.Id() != "") + advancedRef, err := expandArmAutomationScheduleAdvanced(vl, isUpdate) if err != nil { return err } properties.AdvancedSchedule = advancedRef } - } else { - // To make sure all the properties are unset in the event of removal, pass in an empty skeleton object + } else if isUpdate { + // To make sure all the properties are unset in the event of removal update, pass in an empty skeleton object properties.AdvancedSchedule = &automation.AdvancedSchedule{ WeekDays: &[]string{}, MonthDays: &[]int32{}, @@ -388,7 +389,7 @@ func resourceArmAutomationScheduleDelete(d *schema.ResourceData, meta interface{ return nil } -func expandArmAutomationScheduleAdvanced(v []interface{}, update bool) (*automation.AdvancedSchedule, error) { +func expandArmAutomationScheduleAdvanced(v []interface{}, isUpdate bool) (*automation.AdvancedSchedule, error) { // Get the one and only advance schedule configuration advancedSchedule := v[0].(map[string]interface{}) @@ -400,7 +401,7 @@ func expandArmAutomationScheduleAdvanced(v []interface{}, update bool) (*automat // If frequency is set to `Month` the `week_days` array cannot be set (even empty), otherwise the API returns an error. // During update it can be set and it will not return an error. Workaround for the APIs behavior - if len(weekDays) > 0 || update { + if len(weekDays) > 0 || isUpdate { expandedWeekDays := make([]string, len(weekDays)) for i := range weekDays { expandedWeekDays[i] = weekDays[i].(string) @@ -409,7 +410,7 @@ func expandArmAutomationScheduleAdvanced(v []interface{}, update bool) (*automat } // Same as above with `week_days` - if len(monthDays) > 0 || update { + if len(monthDays) > 0 || isUpdate { expandedMonthDays := make([]int32, len(monthDays)) for i := range monthDays { expandedMonthDays[i] = int32(monthDays[i].(int)) @@ -433,7 +434,8 @@ func expandArmAutomationScheduleAdvanced(v []interface{}, update bool) (*automat } func flattenArmAutomationScheduleAdvanced(v *automation.AdvancedSchedule) []interface{} { - if v == nil { + // If all the elements in the advanced schedule are `nil` it's assumed it doesn't exist + if v == nil || (v.WeekDays == nil && v.MonthDays == nil && v.MonthlyOccurrences == nil) { return []interface{}{} } From c4a37df101eaf610640beb640d393e4cc470ce1d Mon Sep 17 00:00:00 2001 From: Leo Date: Mon, 30 Jul 2018 14:42:26 +0100 Subject: [PATCH 06/95] New Resource: `azurerm_service_fabric_cluster` (#4) * Adding azure service fabric resource * Vendoring `2018-02-01` of the ServiceFabric SDK * Adding back in the client definition / changes needed to get it to compile * Renaming to Service Fabric Cluster * Registering the Microsoft.ServiceFabric client * Refactoring Service Fabric Clusters to use nested objects * Service Fabric Cluster; fixes, import support and acceptance tests Tests pass: ``` $ acctests azurerm TestAccAzureRMServiceFabricCluster_ === RUN TestAccAzureRMServiceFabricCluster_basic --- PASS: TestAccAzureRMServiceFabricCluster_basic (65.66s) === RUN TestAccAzureRMServiceFabricCluster_addOnFeatures --- PASS: TestAccAzureRMServiceFabricCluster_addOnFeatures (54.47s) === RUN TestAccAzureRMServiceFabricCluster_certificate --- PASS: TestAccAzureRMServiceFabricCluster_certificate (68.11s) === RUN TestAccAzureRMServiceFabricCluster_clientCertificateThumbprint --- PASS: TestAccAzureRMServiceFabricCluster_clientCertificateThumbprint (59.19s) === RUN TestAccAzureRMServiceFabricCluster_diagnosticsConfig --- PASS: TestAccAzureRMServiceFabricCluster_diagnosticsConfig (82.73s) === RUN TestAccAzureRMServiceFabricCluster_fabricSettings --- PASS: TestAccAzureRMServiceFabricCluster_fabricSettings (61.09s) === RUN TestAccAzureRMServiceFabricCluster_fabricSettingsRemove --- PASS: TestAccAzureRMServiceFabricCluster_fabricSettingsRemove (76.76s) === RUN TestAccAzureRMServiceFabricCluster_nodeTypeCustomPorts --- PASS: TestAccAzureRMServiceFabricCluster_nodeTypeCustomPorts (67.23s) === RUN TestAccAzureRMServiceFabricCluster_nodeTypesMultiple --- PASS: TestAccAzureRMServiceFabricCluster_nodeTypesMultiple (65.39s) === RUN TestAccAzureRMServiceFabricCluster_nodeTypesUpdate --- PASS: TestAccAzureRMServiceFabricCluster_nodeTypesUpdate (65.42s) === RUN TestAccAzureRMServiceFabricCluster_tags --- PASS: TestAccAzureRMServiceFabricCluster_tags (62.97s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 729.355s ``` * Documenting the Service Fabric Cluster resource * Documenting the `cluster_endpoint` field --- azurerm/config.go | 13 +- azurerm/provider.go | 2 + .../resource_arm_service_fabric_cluster.go | 824 ++++ ...esource_arm_service_fabric_cluster_test.go | 727 +++ .../2018-02-01/servicefabric/applications.go | 402 ++ .../servicefabric/applicationtypes.go | 322 ++ .../servicefabric/applicationtypeversions.go | 342 ++ .../mgmt/2018-02-01/servicefabric/client.go | 51 + .../mgmt/2018-02-01/servicefabric/clusters.go | 504 +++ .../servicefabric/clusterversions.go | 308 ++ .../mgmt/2018-02-01/servicefabric/models.go | 3982 +++++++++++++++++ .../2018-02-01/servicefabric/operations.go | 126 + .../mgmt/2018-02-01/servicefabric/services.go | 412 ++ .../mgmt/2018-02-01/servicefabric/version.go | 30 + vendor/vendor.json | 24 +- website/azurerm.erb | 9 + .../r/service_fabric_cluster.html.markdown | 168 + 17 files changed, 8237 insertions(+), 9 deletions(-) create mode 100644 azurerm/resource_arm_service_fabric_cluster.go create mode 100644 azurerm/resource_arm_service_fabric_cluster_test.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applications.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applicationtypes.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applicationtypeversions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/clusters.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/clusterversions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/operations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/services.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/version.go create mode 100644 website/docs/r/service_fabric_cluster.html.markdown diff --git a/azurerm/config.go b/azurerm/config.go index 141c0bef60b00..5b02f11c51f03 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -49,6 +49,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/scheduler/mgmt/2016-03-01/scheduler" "github.com/Azure/azure-sdk-for-go/services/search/mgmt/2015-08-19/search" "github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus" + "github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/trafficmanager/mgmt/2017-05-01/trafficmanager" "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2018-02-01/web" @@ -211,7 +212,7 @@ type ArmClient struct { resourceGroupsClient resources.GroupsClient subscriptionsClient subscriptions.Client - //Scheduler + // Scheduler schedulerJobCollectionsClient scheduler.JobCollectionsClient schedulerJobsClient scheduler.JobsClient @@ -225,6 +226,9 @@ type ArmClient struct { serviceBusSubscriptionsClient servicebus.SubscriptionsClient serviceBusSubscriptionRulesClient servicebus.RulesClient + // Service Fabric + serviceFabricClustersClient servicefabric.ClustersClient + // Storage storageServiceClient storage.AccountsClient storageUsageClient storage.UsageClient @@ -428,6 +432,7 @@ func getArmClient(c *authentication.Config) (*ArmClient, error) { client.registerResourcesClients(endpoint, c.SubscriptionID, auth) client.registerSearchClients(endpoint, c.SubscriptionID, auth) client.registerServiceBusClients(endpoint, c.SubscriptionID, auth) + client.registerServiceFabricClients(endpoint, c.SubscriptionID, auth) client.registerSchedulerClients(endpoint, c.SubscriptionID, auth) client.registerStorageClients(endpoint, c.SubscriptionID, auth) client.registerTrafficManagerClients(endpoint, c.SubscriptionID, auth) @@ -979,6 +984,12 @@ func (c *ArmClient) registerServiceBusClients(endpoint, subscriptionId string, a c.serviceBusSubscriptionRulesClient = subscriptionRulesClient } +func (c *ArmClient) registerServiceFabricClients(endpoint, subscriptionId string, auth autorest.Authorizer) { + clustersClient := servicefabric.NewClustersClientWithBaseURI(endpoint, subscriptionId) + c.configureClient(&clustersClient.Client, auth) + c.serviceFabricClustersClient = clustersClient +} + func (c *ArmClient) registerStorageClients(endpoint, subscriptionId string, auth autorest.Authorizer) { accountsClient := storage.NewAccountsClientWithBaseURI(endpoint, subscriptionId) c.configureClient(&accountsClient.Client, auth) diff --git a/azurerm/provider.go b/azurerm/provider.go index dd6d83e163a73..35889a2774edd 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -233,6 +233,7 @@ func Provider() terraform.ResourceProvider { "azurerm_servicebus_subscription_rule": resourceArmServiceBusSubscriptionRule(), "azurerm_servicebus_topic": resourceArmServiceBusTopic(), "azurerm_servicebus_topic_authorization_rule": resourceArmServiceBusTopicAuthorizationRule(), + "azurerm_service_fabric_cluster": resourceArmServiceFabricCluster(), "azurerm_snapshot": resourceArmSnapshot(), "azurerm_scheduler_job": resourceArmSchedulerJob(), "azurerm_scheduler_job_collection": resourceArmSchedulerJobCollection(), @@ -386,6 +387,7 @@ func determineAzureResourceProvidersToRegister(providerList []resources.Provider "Microsoft.Resources": {}, "Microsoft.Search": {}, "Microsoft.ServiceBus": {}, + "Microsoft.ServiceFabric": {}, "Microsoft.Sql": {}, "Microsoft.Storage": {}, } diff --git a/azurerm/resource_arm_service_fabric_cluster.go b/azurerm/resource_arm_service_fabric_cluster.go new file mode 100644 index 0000000000000..8ddd315ad51ac --- /dev/null +++ b/azurerm/resource_arm_service_fabric_cluster.go @@ -0,0 +1,824 @@ +package azurerm + +import ( + "fmt" + "log" + + "github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmServiceFabricCluster() *schema.Resource { + return &schema.Resource{ + Create: resourceArmServiceFabricClusterCreate, + Read: resourceArmServiceFabricClusterRead, + Update: resourceArmServiceFabricClusterUpdate, + Delete: resourceArmServiceFabricClusterDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "resource_group_name": resourceGroupNameSchema(), + + "location": locationSchema(), + + "reliability_level": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(servicefabric.ReliabilityLevelNone), + string(servicefabric.ReliabilityLevelBronze), + string(servicefabric.ReliabilityLevelSilver), + string(servicefabric.ReliabilityLevelGold), + string(servicefabric.ReliabilityLevelPlatinum), + }, false), + }, + + "upgrade_mode": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(servicefabric.Automatic), + string(servicefabric.Manual), + }, false), + }, + + "management_endpoint": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "vm_image": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "add_on_features": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: schema.HashString, + }, + + "certificate": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "thumbprint": { + Type: schema.TypeString, + Required: true, + }, + "thumbprint_secondary": { + Type: schema.TypeString, + Optional: true, + }, + "x509_store_name": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + + "client_certificate_thumbprint": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "thumbprint": { + Type: schema.TypeString, + Required: true, + }, + "is_admin": { + Type: schema.TypeBool, + Required: true, + }, + }, + }, + }, + + "diagnostics_config": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "storage_account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "protected_account_key_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "blob_endpoint": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "queue_endpoint": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "table_endpoint": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + }, + }, + }, + + "fabric_settings": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "parameters": { + Type: schema.TypeMap, + Optional: true, + }, + }, + }, + }, + + "node_type": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "instance_count": { + Type: schema.TypeInt, + Required: true, + }, + "is_primary": { + Type: schema.TypeBool, + Required: true, + ForceNew: true, + }, + "client_endpoint_port": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + }, + "http_endpoint_port": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + }, + "durability_level": { + Type: schema.TypeString, + Optional: true, + Default: string(servicefabric.Bronze), + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(servicefabric.Bronze), + string(servicefabric.Gold), + string(servicefabric.Silver), + }, false), + }, + + "application_ports": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "start_port": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + }, + "end_port": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + }, + }, + }, + }, + + "ephemeral_ports": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "start_port": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + }, + "end_port": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + }, + }, + }, + }, + }, + }, + }, + + "tags": tagsSchema(), + + "cluster_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceArmServiceFabricClusterCreate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).serviceFabricClustersClient + ctx := meta.(*ArmClient).StopContext + + log.Printf("[INFO] preparing arguments for Service Fabric Cluster creation.") + + resourceGroup := d.Get("resource_group_name").(string) + name := d.Get("name").(string) + location := d.Get("location").(string) + reliabilityLevel := d.Get("reliability_level").(string) + managementEndpoint := d.Get("management_endpoint").(string) + upgradeMode := d.Get("upgrade_mode").(string) + vmImage := d.Get("vm_image").(string) + tags := d.Get("tags").(map[string]interface{}) + + addOnFeaturesRaw := d.Get("add_on_features").(*schema.Set).List() + addOnFeatures := expandServiceFabricClusterAddOnFeatures(addOnFeaturesRaw) + + certificateRaw := d.Get("certificate").([]interface{}) + certificate := expandServiceFabricClusterCertificate(certificateRaw) + + clientCertificateThumbprintRaw := d.Get("client_certificate_thumbprint").([]interface{}) + clientCertificateThumbprints := expandServiceFabricClusterClientCertificateThumbprints(clientCertificateThumbprintRaw) + + diagnosticsRaw := d.Get("diagnostics_config").([]interface{}) + diagnostics := expandServiceFabricClusterDiagnosticsConfig(diagnosticsRaw) + + fabricSettingsRaw := d.Get("fabric_settings").([]interface{}) + fabricSettings := expandServiceFabricClusterFabricSettings(fabricSettingsRaw) + + nodeTypesRaw := d.Get("node_type").([]interface{}) + nodeTypes := expandServiceFabricClusterNodeTypes(nodeTypesRaw) + + cluster := servicefabric.Cluster{ + Location: utils.String(location), + Tags: expandTags(tags), + ClusterProperties: &servicefabric.ClusterProperties{ + AddOnFeatures: addOnFeatures, + Certificate: certificate, + ClientCertificateThumbprints: clientCertificateThumbprints, + DiagnosticsStorageAccountConfig: diagnostics, + FabricSettings: fabricSettings, + ManagementEndpoint: utils.String(managementEndpoint), + NodeTypes: nodeTypes, + ReliabilityLevel: servicefabric.ReliabilityLevel(reliabilityLevel), + UpgradeMode: servicefabric.UpgradeMode(upgradeMode), + VMImage: utils.String(vmImage), + }, + } + + future, err := client.Create(ctx, resourceGroup, name, cluster) + if err != nil { + return fmt.Errorf("Error creating Service Fabric Cluster %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + err = future.WaitForCompletionRef(ctx, client.Client) + if err != nil { + return fmt.Errorf("Error waiting for creation of Service Fabric Cluster %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + read, err := client.Get(ctx, resourceGroup, name) + if err != nil { + return fmt.Errorf("Error retrieving Service Fabric Cluster %q (Resource Group %q): %+v", name, resourceGroup, err) + } + if read.ID == nil { + return fmt.Errorf("Cannot read ID of Service Fabric Cluster %q (Resource Group %q)", name, resourceGroup) + } + + d.SetId(*read.ID) + + return resourceArmServiceFabricClusterRead(d, meta) +} + +func resourceArmServiceFabricClusterUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).serviceFabricClustersClient + ctx := meta.(*ArmClient).StopContext + + log.Printf("[INFO] preparing arguments for Service Fabric Cluster update.") + + resourceGroup := d.Get("resource_group_name").(string) + name := d.Get("name").(string) + reliabilityLevel := d.Get("reliability_level").(string) + upgradeMode := d.Get("upgrade_mode").(string) + tags := d.Get("tags").(map[string]interface{}) + + addOnFeaturesRaw := d.Get("add_on_features").(*schema.Set).List() + addOnFeatures := expandServiceFabricClusterAddOnFeatures(addOnFeaturesRaw) + + certificateRaw := d.Get("certificate").([]interface{}) + certificate := expandServiceFabricClusterCertificate(certificateRaw) + + clientCertificateThumbprintsRaw := d.Get("client_certificate_thumbprint").([]interface{}) + clientCertificateThumbprints := expandServiceFabricClusterClientCertificateThumbprints(clientCertificateThumbprintsRaw) + + fabricSettingsRaw := d.Get("fabric_settings").([]interface{}) + fabricSettings := expandServiceFabricClusterFabricSettings(fabricSettingsRaw) + + nodeTypesRaw := d.Get("node_type").([]interface{}) + nodeTypes := expandServiceFabricClusterNodeTypes(nodeTypesRaw) + + parameters := servicefabric.ClusterUpdateParameters{ + ClusterPropertiesUpdateParameters: &servicefabric.ClusterPropertiesUpdateParameters{ + AddOnFeatures: addOnFeatures, + Certificate: certificate, + ClientCertificateThumbprints: clientCertificateThumbprints, + FabricSettings: fabricSettings, + NodeTypes: nodeTypes, + ReliabilityLevel: servicefabric.ReliabilityLevel1(reliabilityLevel), + UpgradeMode: servicefabric.UpgradeMode1(upgradeMode), + }, + Tags: expandTags(tags), + } + + future, err := client.Update(ctx, resourceGroup, name, parameters) + if err != nil { + return fmt.Errorf("Error updating Service Fabric Cluster %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + err = future.WaitForCompletionRef(ctx, client.Client) + if err != nil { + return fmt.Errorf("Error waiting for update of Service Fabric Cluster %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + return resourceArmServiceFabricClusterRead(d, meta) +} + +func resourceArmServiceFabricClusterRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).serviceFabricClustersClient + ctx := meta.(*ArmClient).StopContext + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + + resourceGroup := id.ResourceGroup + name := id.Path["clusters"] + + resp, err := client.Get(ctx, resourceGroup, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[WARN] Service Fabric Cluster %q (Resource Group %q) was not found - removing from state!", name, resourceGroup) + d.SetId("") + return nil + } + + return fmt.Errorf("Error retrieving Service Fabric Cluster %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + d.Set("name", name) + d.Set("resource_group_name", resourceGroup) + if location := resp.Location; location != nil { + d.Set("location", azureRMNormalizeLocation(*location)) + } + + if props := resp.ClusterProperties; props != nil { + d.Set("cluster_endpoint", props.ClusterEndpoint) + d.Set("management_endpoint", props.ManagementEndpoint) + d.Set("reliability_level", string(props.ReliabilityLevel)) + d.Set("upgrade_mode", string(props.UpgradeMode)) + d.Set("vm_image", props.VMImage) + + addOnFeatures := flattenServiceFabricClusterAddOnFeatures(props.AddOnFeatures) + if err := d.Set("add_on_features", schema.NewSet(schema.HashString, addOnFeatures)); err != nil { + return fmt.Errorf("Error setting `add_on_features`: %+v", err) + } + + certificate := flattenServiceFabricClusterCertificate(props.Certificate) + if err := d.Set("certificate", certificate); err != nil { + return fmt.Errorf("Error setting `certificate`: %+v", err) + } + + clientCertificateThumbprints := flattenServiceFabricClusterClientCertificateThumbprints(props.ClientCertificateThumbprints) + if err := d.Set("client_certificate_thumbprint", clientCertificateThumbprints); err != nil { + return fmt.Errorf("Error setting `client_certificate_thumbprint`: %+v", err) + } + + diagnostics := flattenServiceFabricClusterDiagnosticsConfig(props.DiagnosticsStorageAccountConfig) + if err := d.Set("diagnostics_config", diagnostics); err != nil { + return fmt.Errorf("Error setting `diagnostics_config`: %+v", err) + } + + fabricSettings := flattenServiceFabricClusterFabricSettings(props.FabricSettings) + if err := d.Set("fabric_settings", fabricSettings); err != nil { + return fmt.Errorf("Error setting `fabric_settings`: %+v", err) + } + + nodeTypes := flattenServiceFabricClusterNodeTypes(props.NodeTypes) + if err := d.Set("node_type", nodeTypes); err != nil { + return fmt.Errorf("Error setting `node_type`: %+v", err) + } + } + + flattenAndSetTags(d, resp.Tags) + + return nil +} + +func resourceArmServiceFabricClusterDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).serviceFabricClustersClient + ctx := meta.(*ArmClient).StopContext + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + resourceGroup := id.ResourceGroup + name := id.Path["clusters"] + + log.Printf("[DEBUG] Deleting Service Fabric Cluster %q (Resource Group %q)", name, resourceGroup) + + resp, err := client.Delete(ctx, resourceGroup, name) + if err != nil { + if !response.WasNotFound(resp.Response) { + return fmt.Errorf("Error deleting Service Fabric Cluster %q (Resource Group %q): %+v", name, resourceGroup, err) + } + } + + return nil +} + +func expandServiceFabricClusterAddOnFeatures(input []interface{}) *[]string { + output := make([]string, 0) + + for _, v := range input { + output = append(output, v.(string)) + } + + return &output +} + +func flattenServiceFabricClusterAddOnFeatures(input *[]string) []interface{} { + output := make([]interface{}, 0) + + if input != nil { + for _, v := range *input { + output = append(output, v) + } + } + + return output +} + +func expandServiceFabricClusterCertificate(input []interface{}) *servicefabric.CertificateDescription { + if len(input) == 0 { + return nil + } + + v := input[0].(map[string]interface{}) + + thumbprint := v["thumbprint"].(string) + x509StoreName := v["x509_store_name"].(string) + + result := servicefabric.CertificateDescription{ + Thumbprint: utils.String(thumbprint), + X509StoreName: servicefabric.X509StoreName(x509StoreName), + } + + if thumb, ok := v["thumbprint_secondary"]; ok { + result.ThumbprintSecondary = utils.String(thumb.(string)) + } + + return &result +} + +func flattenServiceFabricClusterCertificate(input *servicefabric.CertificateDescription) []interface{} { + results := make([]interface{}, 0) + + if v := input; v != nil { + output := make(map[string]interface{}, 0) + + if thumbprint := input.Thumbprint; thumbprint != nil { + output["thumbprint"] = *thumbprint + } + + if thumbprint := input.ThumbprintSecondary; thumbprint != nil { + output["thumbprint_secondary"] = *thumbprint + } + + output["x509_store_name"] = string(input.X509StoreName) + results = append(results, output) + } + + return results +} + +func expandServiceFabricClusterClientCertificateThumbprints(input []interface{}) *[]servicefabric.ClientCertificateThumbprint { + results := make([]servicefabric.ClientCertificateThumbprint, 0) + + for _, v := range input { + val := v.(map[string]interface{}) + + thumbprint := val["thumbprint"].(string) + isAdmin := val["is_admin"].(bool) + + result := servicefabric.ClientCertificateThumbprint{ + CertificateThumbprint: utils.String(thumbprint), + IsAdmin: utils.Bool(isAdmin), + } + results = append(results, result) + } + + return &results +} + +func flattenServiceFabricClusterClientCertificateThumbprints(input *[]servicefabric.ClientCertificateThumbprint) []interface{} { + if input == nil { + return []interface{}{} + } + + results := make([]interface{}, 0) + + for _, v := range *input { + result := make(map[string]interface{}, 0) + + if thumbprint := v.CertificateThumbprint; thumbprint != nil { + result["thumbprint"] = *thumbprint + } + + if isAdmin := v.IsAdmin; isAdmin != nil { + result["is_admin"] = *isAdmin + } + + results = append(results, result) + } + + return results +} + +func expandServiceFabricClusterDiagnosticsConfig(input []interface{}) *servicefabric.DiagnosticsStorageAccountConfig { + if len(input) == 0 { + return nil + } + + v := input[0].(map[string]interface{}) + + storageAccountName := v["storage_account_name"].(string) + protectedAccountKeyName := v["protected_account_key_name"].(string) + blobEndpoint := v["blob_endpoint"].(string) + queueEndpoint := v["queue_endpoint"].(string) + tableEndpoint := v["table_endpoint"].(string) + + config := servicefabric.DiagnosticsStorageAccountConfig{ + StorageAccountName: utils.String(storageAccountName), + ProtectedAccountKeyName: utils.String(protectedAccountKeyName), + BlobEndpoint: utils.String(blobEndpoint), + QueueEndpoint: utils.String(queueEndpoint), + TableEndpoint: utils.String(tableEndpoint), + } + return &config +} + +func flattenServiceFabricClusterDiagnosticsConfig(input *servicefabric.DiagnosticsStorageAccountConfig) []interface{} { + results := make([]interface{}, 0) + + if v := input; v != nil { + output := make(map[string]interface{}, 0) + + if name := v.StorageAccountName; name != nil { + output["storage_account_name"] = *name + } + + if name := v.ProtectedAccountKeyName; name != nil { + output["protected_account_key_name"] = *name + } + + if endpoint := v.BlobEndpoint; endpoint != nil { + output["blob_endpoint"] = *endpoint + } + + if endpoint := v.QueueEndpoint; endpoint != nil { + output["queue_endpoint"] = *endpoint + } + + if endpoint := v.TableEndpoint; endpoint != nil { + output["table_endpoint"] = *endpoint + } + + results = append(results, output) + } + + return results +} + +func expandServiceFabricClusterFabricSettings(input []interface{}) *[]servicefabric.SettingsSectionDescription { + results := make([]servicefabric.SettingsSectionDescription, 0) + + for _, v := range input { + val := v.(map[string]interface{}) + + name := val["name"].(string) + params := make([]servicefabric.SettingsParameterDescription, 0) + paramsRaw := val["parameters"].(map[string]interface{}) + for k, v := range paramsRaw { + param := servicefabric.SettingsParameterDescription{ + Name: utils.String(k), + Value: utils.String(v.(string)), + } + params = append(params, param) + } + + result := servicefabric.SettingsSectionDescription{ + Name: utils.String(name), + Parameters: ¶ms, + } + results = append(results, result) + } + + return &results +} + +func flattenServiceFabricClusterFabricSettings(input *[]servicefabric.SettingsSectionDescription) []interface{} { + if input == nil { + return []interface{}{} + } + + results := make([]interface{}, 0) + + for _, v := range *input { + result := make(map[string]interface{}, 0) + + if name := v.Name; name != nil { + result["name"] = *name + } + + parameters := make(map[string]interface{}, 0) + if paramsRaw := v.Parameters; paramsRaw != nil { + for _, p := range *paramsRaw { + if p.Name == nil || p.Value == nil { + continue + } + + parameters[*p.Name] = *p.Value + } + } + result["parameters"] = parameters + results = append(results, result) + } + + return results +} + +func expandServiceFabricClusterNodeTypes(input []interface{}) *[]servicefabric.NodeTypeDescription { + results := make([]servicefabric.NodeTypeDescription, 0) + + for _, v := range input { + node := v.(map[string]interface{}) + + name := node["name"].(string) + instanceCount := node["instance_count"].(int) + clientEndpointPort := node["client_endpoint_port"].(int) + httpEndpointPort := node["http_endpoint_port"].(int) + isPrimary := node["is_primary"].(bool) + durabilityLevel := node["durability_level"].(string) + + result := servicefabric.NodeTypeDescription{ + Name: utils.String(name), + VMInstanceCount: utils.Int32(int32(instanceCount)), + IsPrimary: utils.Bool(isPrimary), + ClientConnectionEndpointPort: utils.Int32(int32(clientEndpointPort)), + HTTPGatewayEndpointPort: utils.Int32(int32(httpEndpointPort)), + DurabilityLevel: servicefabric.DurabilityLevel(durabilityLevel), + } + + applicationPortsRaw := node["application_ports"].([]interface{}) + if len(applicationPortsRaw) > 0 { + portsRaw := applicationPortsRaw[0].(map[string]interface{}) + + startPort := portsRaw["start_port"].(int) + endPort := portsRaw["end_port"].(int) + + result.ApplicationPorts = &servicefabric.EndpointRangeDescription{ + StartPort: utils.Int32(int32(startPort)), + EndPort: utils.Int32(int32(endPort)), + } + } + + ephemeralPortsRaw := node["ephemeral_ports"].([]interface{}) + if len(ephemeralPortsRaw) > 0 { + portsRaw := ephemeralPortsRaw[0].(map[string]interface{}) + + startPort := portsRaw["start_port"].(int) + endPort := portsRaw["end_port"].(int) + + result.EphemeralPorts = &servicefabric.EndpointRangeDescription{ + StartPort: utils.Int32(int32(startPort)), + EndPort: utils.Int32(int32(endPort)), + } + } + + results = append(results, result) + } + + return &results +} + +func flattenServiceFabricClusterNodeTypes(input *[]servicefabric.NodeTypeDescription) []interface{} { + if input == nil { + return []interface{}{} + } + + results := make([]interface{}, 0) + + for _, v := range *input { + output := make(map[string]interface{}, 0) + + if name := v.Name; name != nil { + output["name"] = *name + } + + if count := v.VMInstanceCount; count != nil { + output["instance_count"] = int(*count) + } + + if primary := v.IsPrimary; primary != nil { + output["is_primary"] = *primary + } + + if port := v.ClientConnectionEndpointPort; port != nil { + output["client_endpoint_port"] = *port + } + + if port := v.HTTPGatewayEndpointPort; port != nil { + output["http_endpoint_port"] = *port + } + + output["durability_level"] = string(v.DurabilityLevel) + + applicationPorts := make([]interface{}, 0) + if ports := v.ApplicationPorts; ports != nil { + r := make(map[string]interface{}, 0) + if start := ports.StartPort; start != nil { + r["start_port"] = int(*start) + } + if end := ports.EndPort; end != nil { + r["end_port"] = int(*end) + } + applicationPorts = append(applicationPorts, r) + } + output["application_ports"] = applicationPorts + + ephermeralPorts := make([]interface{}, 0) + if ports := v.EphemeralPorts; ports != nil { + r := make(map[string]interface{}, 0) + if start := ports.StartPort; start != nil { + r["start_port"] = int(*start) + } + if end := ports.EndPort; end != nil { + r["end_port"] = int(*end) + } + ephermeralPorts = append(ephermeralPorts, r) + } + output["ephemeral_ports"] = ephermeralPorts + + results = append(results, output) + } + + return results +} diff --git a/azurerm/resource_arm_service_fabric_cluster_test.go b/azurerm/resource_arm_service_fabric_cluster_test.go new file mode 100644 index 0000000000000..439eea3a56fad --- /dev/null +++ b/azurerm/resource_arm_service_fabric_cluster_test.go @@ -0,0 +1,727 @@ +package azurerm + +import ( + "fmt" + "net/http" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" +) + +func TestAccAzureRMServiceFabricCluster_basic(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + config := testAccAzureRMServiceFabricCluster_basic(ri, location, 3) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "management_endpoint", "http://example:80"), + resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "0"), + resource.TestCheckResourceAttr(resourceName, "certificate.#", "0"), + resource.TestCheckResourceAttr(resourceName, "client_certificate_thumbprint.#", "0"), + resource.TestCheckResourceAttr(resourceName, "diagnostics_config.#", "0"), + resource.TestCheckResourceAttr(resourceName, "node_type.#", "1"), + resource.TestCheckResourceAttr(resourceName, "node_type.0.instance_count", "3"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMServiceFabricCluster_addOnFeatures(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + config := testAccAzureRMServiceFabricCluster_addOnFeatures(ri, location) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "2"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMServiceFabricCluster_certificate(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMServiceFabricCluster_certificates(ri, location), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "certificate.#", "1"), + resource.TestCheckResourceAttr(resourceName, "certificate.0.thumbprint", "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE"), + resource.TestCheckResourceAttr(resourceName, "certificate.0.x509_store_name", "My"), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.ClusterProtectionLevel", "EncryptAndSign"), + resource.TestCheckResourceAttr(resourceName, "management_endpoint", "https://example:80"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMServiceFabricCluster_clientCertificateThumbprint(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMServiceFabricCluster_clientCertificateThumbprint(ri, location), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "certificate.#", "1"), + resource.TestCheckResourceAttr(resourceName, "certificate.0.thumbprint", "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE"), + resource.TestCheckResourceAttr(resourceName, "certificate.0.x509_store_name", "My"), + resource.TestCheckResourceAttr(resourceName, "client_certificate_thumbprint.#", "1"), + resource.TestCheckResourceAttr(resourceName, "client_certificate_thumbprint.0.thumbprint", "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE"), + resource.TestCheckResourceAttr(resourceName, "client_certificate_thumbprint.0.is_admin", "true"), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.ClusterProtectionLevel", "EncryptAndSign"), + resource.TestCheckResourceAttr(resourceName, "management_endpoint", "https://example:80"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMServiceFabricCluster_diagnosticsConfig(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + rs := acctest.RandString(4) + location := testLocation() + config := testAccAzureRMServiceFabricCluster_diagnosticsConfig(ri, rs, location) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "diagnostics_config.#", "1"), + resource.TestCheckResourceAttrSet(resourceName, "diagnostics_config.0.storage_account_name"), + resource.TestCheckResourceAttrSet(resourceName, "diagnostics_config.0.protected_account_key_name"), + resource.TestCheckResourceAttrSet(resourceName, "diagnostics_config.0.blob_endpoint"), + resource.TestCheckResourceAttrSet(resourceName, "diagnostics_config.0.queue_endpoint"), + resource.TestCheckResourceAttrSet(resourceName, "diagnostics_config.0.table_endpoint"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMServiceFabricCluster_fabricSettings(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + config := testAccAzureRMServiceFabricCluster_fabricSettings(ri, location) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.#", "1"), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.%", "1"), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.ClusterProtectionLevel", "None"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMServiceFabricCluster_fabricSettingsRemove(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMServiceFabricCluster_fabricSettings(ri, location), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.#", "1"), + ), + }, + { + Config: testAccAzureRMServiceFabricCluster_basic(ri, location, 3), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "fabric_settings.#", "0"), + ), + }, + }, + }) +} + +func TestAccAzureRMServiceFabricCluster_nodeTypeCustomPorts(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + config := testAccAzureRMServiceFabricCluster_nodeTypeCustomPorts(ri, location) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "node_type.#", "1"), + resource.TestCheckResourceAttr(resourceName, "node_type.0.application_ports.#", "1"), + resource.TestCheckResourceAttr(resourceName, "node_type.0.application_ports.0.start_port", "20000"), + resource.TestCheckResourceAttr(resourceName, "node_type.0.application_ports.0.end_port", "29999"), + resource.TestCheckResourceAttr(resourceName, "node_type.0.ephemeral_ports.#", "1"), + resource.TestCheckResourceAttr(resourceName, "node_type.0.ephemeral_ports.0.start_port", "30000"), + resource.TestCheckResourceAttr(resourceName, "node_type.0.ephemeral_ports.0.end_port", "39999"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMServiceFabricCluster_nodeTypesMultiple(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + config := testAccAzureRMServiceFabricCluster_nodeTypeMultiple(ri, location) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "node_type.#", "2"), + resource.TestCheckResourceAttr(resourceName, "node_type.0.name", "first"), + resource.TestCheckResourceAttr(resourceName, "node_type.0.instance_count", "3"), + resource.TestCheckResourceAttr(resourceName, "node_type.0.is_primary", "true"), + resource.TestCheckResourceAttr(resourceName, "node_type.1.name", "second"), + resource.TestCheckResourceAttr(resourceName, "node_type.1.instance_count", "4"), + resource.TestCheckResourceAttr(resourceName, "node_type.1.is_primary", "false"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMServiceFabricCluster_nodeTypesUpdate(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMServiceFabricCluster_basic(ri, location, 3), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "node_type.0.instance_count", "3"), + ), + }, + { + Config: testAccAzureRMServiceFabricCluster_basic(ri, location, 4), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "node_type.0.instance_count", "4"), + ), + }, + }, + }) +} + +func TestAccAzureRMServiceFabricCluster_tags(t *testing.T) { + resourceName := "azurerm_service_fabric_cluster.test" + ri := acctest.RandInt() + location := testLocation() + config := testAccAzureRMServiceFabricCluster_tags(ri, location) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceFabricClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.Hello", "World"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testCheckAzureRMServiceFabricClusterDestroy(s *terraform.State) error { + client := testAccProvider.Meta().(*ArmClient).serviceFabricClustersClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_service_fabric_cluster" { + continue + } + + name := rs.Primary.Attributes["name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + + resp, err := client.Get(ctx, resourceGroup, name) + + if err != nil { + return nil + } + + if resp.StatusCode != http.StatusNotFound { + return fmt.Errorf("Service Fabric Cluster still exists:\n%+v", resp) + } + } + + return nil +} + +func testCheckAzureRMServiceFabricClusterExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + clusterName := rs.Primary.Attributes["name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for Service Fabric Cluster %q", clusterName) + } + + client := testAccProvider.Meta().(*ArmClient).serviceFabricClustersClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + + resp, err := client.Get(ctx, resourceGroup, clusterName) + if err != nil { + return fmt.Errorf("Bad: Get on serviceFabricClustersClient: %+v", err) + } + + if resp.StatusCode == http.StatusNotFound { + return fmt.Errorf("Bad: Service Fabric Cluster %q (Resource Group: %q) does not exist", clusterName, resourceGroup) + } + + return nil + } +} + +func testAccAzureRMServiceFabricCluster_basic(rInt int, location string, count int) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_service_fabric_cluster" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + reliability_level = "Bronze" + upgrade_mode = "Automatic" + vm_image = "Windows" + management_endpoint = "http://example:80" + + node_type { + name = "first" + instance_count = %d + is_primary = true + client_endpoint_port = 2020 + http_endpoint_port = 80 + } +} +`, rInt, location, rInt, count) +} + +func testAccAzureRMServiceFabricCluster_addOnFeatures(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_service_fabric_cluster" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + reliability_level = "Bronze" + upgrade_mode = "Automatic" + vm_image = "Windows" + management_endpoint = "http://example:80" + add_on_features = [ "DnsService", "RepairManager" ] + + node_type { + name = "first" + instance_count = 3 + is_primary = true + client_endpoint_port = 2020 + http_endpoint_port = 80 + } +} +`, rInt, location, rInt) +} + +func testAccAzureRMServiceFabricCluster_certificates(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_service_fabric_cluster" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + reliability_level = "Bronze" + upgrade_mode = "Automatic" + vm_image = "Windows" + management_endpoint = "https://example:80" + + certificate { + thumbprint = "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE" + x509_store_name = "My" + } + + fabric_settings { + name = "Security" + + parameters { + "ClusterProtectionLevel" = "EncryptAndSign" + } + } + + node_type { + name = "first" + instance_count = 3 + is_primary = true + client_endpoint_port = 2020 + http_endpoint_port = 80 + } +} +`, rInt, location, rInt) +} + +func testAccAzureRMServiceFabricCluster_clientCertificateThumbprint(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_service_fabric_cluster" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + reliability_level = "Bronze" + upgrade_mode = "Automatic" + vm_image = "Windows" + management_endpoint = "https://example:80" + + certificate { + thumbprint = "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE" + x509_store_name = "My" + } + + client_certificate_thumbprint { + thumbprint = "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE" + is_admin = true + } + + fabric_settings { + name = "Security" + + parameters { + "ClusterProtectionLevel" = "EncryptAndSign" + } + } + + node_type { + name = "first" + instance_count = 3 + is_primary = true + client_endpoint_port = 2020 + http_endpoint_port = 80 + } +} +`, rInt, location, rInt) +} + +func testAccAzureRMServiceFabricCluster_diagnosticsConfig(rInt int, rString, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestsa%s" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_tier = "Standard" + account_replication_type = "GRS" +} + +resource "azurerm_service_fabric_cluster" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + reliability_level = "Bronze" + upgrade_mode = "Automatic" + vm_image = "Windows" + management_endpoint = "http://example:80" + + diagnostics_config { + storage_account_name = "${azurerm_storage_account.test.name}" + protected_account_key_name = "StorageAccountKey1" + blob_endpoint = "${azurerm_storage_account.test.primary_blob_endpoint}" + queue_endpoint = "${azurerm_storage_account.test.primary_queue_endpoint}" + table_endpoint = "${azurerm_storage_account.test.primary_table_endpoint}" + } + + node_type { + name = "first" + instance_count = 3 + is_primary = true + client_endpoint_port = 2020 + http_endpoint_port = 80 + } +} +`, rInt, location, rString, rInt) +} + +func testAccAzureRMServiceFabricCluster_fabricSettings(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_service_fabric_cluster" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + reliability_level = "Bronze" + upgrade_mode = "Automatic" + vm_image = "Windows" + management_endpoint = "http://example:80" + + fabric_settings { + name = "Security" + + parameters { + "ClusterProtectionLevel" = "None" + } + } + + node_type { + name = "first" + instance_count = 3 + is_primary = true + client_endpoint_port = 2020 + http_endpoint_port = 80 + } +} +`, rInt, location, rInt) +} + +func testAccAzureRMServiceFabricCluster_nodeTypeCustomPorts(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_service_fabric_cluster" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + reliability_level = "Bronze" + upgrade_mode = "Automatic" + vm_image = "Windows" + management_endpoint = "http://example:80" + + node_type { + name = "first" + instance_count = 3 + is_primary = true + client_endpoint_port = 2020 + http_endpoint_port = 80 + + application_ports { + start_port = 20000 + end_port = 29999 + } + + ephemeral_ports { + start_port = 30000 + end_port = 39999 + } + } +} +`, rInt, location, rInt) +} + +func testAccAzureRMServiceFabricCluster_nodeTypeMultiple(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_service_fabric_cluster" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + reliability_level = "Bronze" + upgrade_mode = "Automatic" + vm_image = "Windows" + management_endpoint = "http://example:80" + + node_type { + name = "first" + instance_count = 3 + is_primary = true + client_endpoint_port = 2020 + http_endpoint_port = 80 + } + + node_type { + name = "second" + instance_count = 4 + is_primary = false + client_endpoint_port = 2121 + http_endpoint_port = 81 + } +} +`, rInt, location, rInt) +} + +func testAccAzureRMServiceFabricCluster_tags(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_service_fabric_cluster" "test" { + name = "acctest-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + reliability_level = "Bronze" + upgrade_mode = "Automatic" + vm_image = "Windows" + management_endpoint = "http://example:80" + + node_type { + name = "first" + instance_count = 3 + is_primary = true + client_endpoint_port = 2020 + http_endpoint_port = 80 + } + + tags { + "Hello" = "World" + } +} +`, rInt, location, rInt) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applications.go b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applications.go new file mode 100644 index 0000000000000..b7bb79b05103c --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applications.go @@ -0,0 +1,402 @@ +package servicefabric + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ApplicationsClient is the service Fabric Management Client +type ApplicationsClient struct { + BaseClient +} + +// NewApplicationsClient creates an instance of the ApplicationsClient client. +func NewApplicationsClient(subscriptionID string) ApplicationsClient { + return NewApplicationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplicationsClientWithBaseURI creates an instance of the ApplicationsClient client. +func NewApplicationsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationsClient { + return ApplicationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create or update a Service Fabric application resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationName - the name of the application resource. +// parameters - the application resource. +func (client ApplicationsClient) Create(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, parameters ApplicationResource) (result ApplicationsCreateFuture, err error) { + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, applicationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ApplicationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, parameters ApplicationResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}", pathParameters), + autorest.WithJSON(parameters), + 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 ApplicationsClient) CreateSender(req *http.Request) (future ApplicationsCreateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) CreateResponder(resp *http.Response) (result ApplicationResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a Service Fabric application resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationName - the name of the application resource. +func (client ApplicationsClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, applicationName string) (result ApplicationsDeleteFuture, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, applicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ApplicationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}", 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 ApplicationsClient) DeleteSender(req *http.Request) (future ApplicationsDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) 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 a Service Fabric application resource created or in the process of being created in the Service Fabric +// cluster resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationName - the name of the application resource. +func (client ApplicationsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, applicationName string) (result ApplicationResource, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName, applicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplicationsClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}", 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 ApplicationsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) GetResponder(resp *http.Response) (result ApplicationResource, 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 all application resources created or in the process of being created in the Service Fabric cluster +// resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +func (client ApplicationsClient) List(ctx context.Context, resourceGroupName string, clusterName string) (result ApplicationResourceList, err error) { + req, err := client.ListPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ApplicationsClient) ListPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applications", 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 ApplicationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) ListResponder(resp *http.Response) (result ApplicationResourceList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update a Service Fabric application resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationName - the name of the application resource. +// parameters - the application resource for patch operations. +func (client ApplicationsClient) Update(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, parameters ApplicationResourceUpdate) (result ApplicationsUpdateFuture, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, applicationName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ApplicationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, parameters ApplicationResourceUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ApplicationsClient) UpdateSender(req *http.Request) (future ApplicationsUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ApplicationsClient) UpdateResponder(resp *http.Response) (result ApplicationResourceUpdate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applicationtypes.go b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applicationtypes.go new file mode 100644 index 0000000000000..a552ffd62d44f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applicationtypes.go @@ -0,0 +1,322 @@ +package servicefabric + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ApplicationTypesClient is the service Fabric Management Client +type ApplicationTypesClient struct { + BaseClient +} + +// NewApplicationTypesClient creates an instance of the ApplicationTypesClient client. +func NewApplicationTypesClient(subscriptionID string) ApplicationTypesClient { + return NewApplicationTypesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplicationTypesClientWithBaseURI creates an instance of the ApplicationTypesClient client. +func NewApplicationTypesClientWithBaseURI(baseURI string, subscriptionID string) ApplicationTypesClient { + return ApplicationTypesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create or update a Service Fabric application type name resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationTypeName - the name of the application type name resource. +// parameters - the application type name resource. +func (client ApplicationTypesClient) Create(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, parameters ApplicationTypeResource) (result ApplicationTypeResource, err error) { + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, applicationTypeName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ApplicationTypesClient) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, parameters ApplicationTypeResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationTypeName": autorest.Encode("path", applicationTypeName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}", pathParameters), + autorest.WithJSON(parameters), + 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 ApplicationTypesClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ApplicationTypesClient) CreateResponder(resp *http.Response) (result ApplicationTypeResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a Service Fabric application type name resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationTypeName - the name of the application type name resource. +func (client ApplicationTypesClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string) (result ApplicationTypesDeleteFuture, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, applicationTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ApplicationTypesClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationTypeName": autorest.Encode("path", applicationTypeName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}", 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 ApplicationTypesClient) DeleteSender(req *http.Request) (future ApplicationTypesDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ApplicationTypesClient) 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 a Service Fabric application type name resource created or in the process of being created in the Service +// Fabric cluster resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationTypeName - the name of the application type name resource. +func (client ApplicationTypesClient) Get(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string) (result ApplicationTypeResource, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName, applicationTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplicationTypesClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationTypeName": autorest.Encode("path", applicationTypeName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}", 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 ApplicationTypesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplicationTypesClient) GetResponder(resp *http.Response) (result ApplicationTypeResource, 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 all application type name resources created or in the process of being created in the Service Fabric +// cluster resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +func (client ApplicationTypesClient) List(ctx context.Context, resourceGroupName string, clusterName string) (result ApplicationTypeResourceList, err error) { + req, err := client.ListPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ApplicationTypesClient) ListPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applicationTypes", 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 ApplicationTypesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ApplicationTypesClient) ListResponder(resp *http.Response) (result ApplicationTypeResourceList, 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/servicefabric/mgmt/2018-02-01/servicefabric/applicationtypeversions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applicationtypeversions.go new file mode 100644 index 0000000000000..ea1b415805fa4 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/applicationtypeversions.go @@ -0,0 +1,342 @@ +package servicefabric + +// 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" + "net/http" +) + +// ApplicationTypeVersionsClient is the service Fabric Management Client +type ApplicationTypeVersionsClient struct { + BaseClient +} + +// NewApplicationTypeVersionsClient creates an instance of the ApplicationTypeVersionsClient client. +func NewApplicationTypeVersionsClient(subscriptionID string) ApplicationTypeVersionsClient { + return NewApplicationTypeVersionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplicationTypeVersionsClientWithBaseURI creates an instance of the ApplicationTypeVersionsClient client. +func NewApplicationTypeVersionsClientWithBaseURI(baseURI string, subscriptionID string) ApplicationTypeVersionsClient { + return ApplicationTypeVersionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create or update a Service Fabric application type version resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationTypeName - the name of the application type name resource. +// version - the application type version. +// parameters - the application type version resource. +func (client ApplicationTypeVersionsClient) Create(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, version string, parameters ApplicationTypeVersionResource) (result ApplicationTypeVersionsCreateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ApplicationTypeVersionResourceProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ApplicationTypeVersionResourceProperties.AppPackageURL", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("servicefabric.ApplicationTypeVersionsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, applicationTypeName, version, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ApplicationTypeVersionsClient) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, version string, parameters ApplicationTypeVersionResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationTypeName": autorest.Encode("path", applicationTypeName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "version": autorest.Encode("path", version), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}", pathParameters), + autorest.WithJSON(parameters), + 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 ApplicationTypeVersionsClient) CreateSender(req *http.Request) (future ApplicationTypeVersionsCreateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ApplicationTypeVersionsClient) CreateResponder(resp *http.Response) (result ApplicationTypeVersionResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a Service Fabric application type version resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationTypeName - the name of the application type name resource. +// version - the application type version. +func (client ApplicationTypeVersionsClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, version string) (result ApplicationTypeVersionsDeleteFuture, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, applicationTypeName, version) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ApplicationTypeVersionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, version string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationTypeName": autorest.Encode("path", applicationTypeName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "version": autorest.Encode("path", version), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}", 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 ApplicationTypeVersionsClient) DeleteSender(req *http.Request) (future ApplicationTypeVersionsDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ApplicationTypeVersionsClient) 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 a Service Fabric application type version resource created or in the process of being created in the Service +// Fabric application type name resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationTypeName - the name of the application type name resource. +// version - the application type version. +func (client ApplicationTypeVersionsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, version string) (result ApplicationTypeVersionResource, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName, applicationTypeName, version) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplicationTypeVersionsClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, version string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationTypeName": autorest.Encode("path", applicationTypeName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "version": autorest.Encode("path", version), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}", 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 ApplicationTypeVersionsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplicationTypeVersionsClient) GetResponder(resp *http.Response) (result ApplicationTypeVersionResource, 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 all application type version resources created or in the process of being created in the Service Fabric +// application type name resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationTypeName - the name of the application type name resource. +func (client ApplicationTypeVersionsClient) List(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string) (result ApplicationTypeVersionResourceList, err error) { + req, err := client.ListPreparer(ctx, resourceGroupName, clusterName, applicationTypeName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ApplicationTypeVersionsClient) ListPreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationTypeName": autorest.Encode("path", applicationTypeName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions", 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 ApplicationTypeVersionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ApplicationTypeVersionsClient) ListResponder(resp *http.Response) (result ApplicationTypeVersionResourceList, 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/servicefabric/mgmt/2018-02-01/servicefabric/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/client.go new file mode 100644 index 0000000000000..5d0f53e073fc6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/client.go @@ -0,0 +1,51 @@ +// Package servicefabric implements the Azure ARM Servicefabric service API version . +// +// Service Fabric Management Client +package servicefabric + +// 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 Servicefabric + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Servicefabric. +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. +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/servicefabric/mgmt/2018-02-01/servicefabric/clusters.go b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/clusters.go new file mode 100644 index 0000000000000..9b0d6c108feb3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/clusters.go @@ -0,0 +1,504 @@ +package servicefabric + +// 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" + "net/http" +) + +// ClustersClient is the service Fabric Management Client +type ClustersClient struct { + BaseClient +} + +// NewClustersClient creates an instance of the ClustersClient client. +func NewClustersClient(subscriptionID string) ClustersClient { + return NewClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClustersClientWithBaseURI creates an instance of the ClustersClient client. +func NewClustersClientWithBaseURI(baseURI string, subscriptionID string) ClustersClient { + return ClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create or update a Service Fabric cluster resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// parameters - the cluster resource. +func (client ClustersClient) Create(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster) (result ClustersCreateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ClusterProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.Certificate", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.Certificate.Thumbprint", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.ClusterProperties.DiagnosticsStorageAccountConfig", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.DiagnosticsStorageAccountConfig.StorageAccountName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.DiagnosticsStorageAccountConfig.ProtectedAccountKeyName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.DiagnosticsStorageAccountConfig.BlobEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.DiagnosticsStorageAccountConfig.QueueEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.DiagnosticsStorageAccountConfig.TableEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.ClusterProperties.ManagementEndpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.NodeTypes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.ReverseProxyCertificate", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.ReverseProxyCertificate.Thumbprint", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.ClusterProperties.UpgradeDescription", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.UpgradeDescription.UpgradeReplicaSetCheckTimeout", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.HealthCheckWaitDuration", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.HealthCheckStableDuration", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.HealthCheckRetryTimeout", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.UpgradeTimeout", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.UpgradeDomainTimeout", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.HealthPolicy", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.UpgradeDescription.HealthPolicy.MaxPercentUnhealthyNodes", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.UpgradeDescription.HealthPolicy.MaxPercentUnhealthyNodes", Name: validation.InclusiveMaximum, Rule: 100, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.HealthPolicy.MaxPercentUnhealthyNodes", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}, + }}, + {Target: "parameters.ClusterProperties.UpgradeDescription.HealthPolicy.MaxPercentUnhealthyApplications", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.UpgradeDescription.HealthPolicy.MaxPercentUnhealthyApplications", Name: validation.InclusiveMaximum, Rule: 100, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.HealthPolicy.MaxPercentUnhealthyApplications", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}, + }}, + }}, + {Target: "parameters.ClusterProperties.UpgradeDescription.DeltaHealthPolicy", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.UpgradeDescription.DeltaHealthPolicy.MaxPercentDeltaUnhealthyNodes", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.UpgradeDescription.DeltaHealthPolicy.MaxPercentDeltaUnhealthyNodes", Name: validation.InclusiveMaximum, Rule: 100, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.DeltaHealthPolicy.MaxPercentDeltaUnhealthyNodes", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}, + }}, + {Target: "parameters.ClusterProperties.UpgradeDescription.DeltaHealthPolicy.MaxPercentUpgradeDomainDeltaUnhealthyNodes", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.UpgradeDescription.DeltaHealthPolicy.MaxPercentUpgradeDomainDeltaUnhealthyNodes", Name: validation.InclusiveMaximum, Rule: 100, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.DeltaHealthPolicy.MaxPercentUpgradeDomainDeltaUnhealthyNodes", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}, + }}, + {Target: "parameters.ClusterProperties.UpgradeDescription.DeltaHealthPolicy.MaxPercentDeltaUnhealthyApplications", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ClusterProperties.UpgradeDescription.DeltaHealthPolicy.MaxPercentDeltaUnhealthyApplications", Name: validation.InclusiveMaximum, Rule: 100, Chain: nil}, + {Target: "parameters.ClusterProperties.UpgradeDescription.DeltaHealthPolicy.MaxPercentDeltaUnhealthyApplications", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("servicefabric.ClustersClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ClustersClient) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01" + 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.ServiceFabric/clusters/{clusterName}", pathParameters), + autorest.WithJSON(parameters), + 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 ClustersClient) CreateSender(req *http.Request) (future ClustersCreateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ClustersClient) CreateResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a Service Fabric cluster resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +func (client ClustersClient) Delete(ctx context.Context, resourceGroupName string, clusterName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}", 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 ClustersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get a Service Fabric cluster resource created or in the process of being created in the specified resource +// group. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +func (client ClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string) (result Cluster, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}", 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 ClustersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ClustersClient) GetResponder(resp *http.Response) (result Cluster, 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 all Service Fabric cluster resources created or in the process of being created in the subscription. +func (client ClustersClient) List(ctx context.Context) (result ClusterListResult, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ClustersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/clusters", 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 ClustersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ClustersClient) ListResponder(resp *http.Response) (result ClusterListResult, 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 all Service Fabric cluster resources created or in the process of being created in the +// resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client ClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ClusterListResult, err error) { + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ClustersClient) 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-02-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters", 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 ClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ClustersClient) ListByResourceGroupResponder(resp *http.Response) (result ClusterListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update the configuration of a Service Fabric cluster resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// parameters - the parameters which contains the property value and property name which used to update the +// cluster configuration. +func (client ClustersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, parameters ClusterUpdateParameters) (result ClustersUpdateFuture, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, parameters ClusterUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) UpdateSender(req *http.Request) (future ClustersUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ClustersClient) UpdateResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/clusterversions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/clusterversions.go new file mode 100644 index 0000000000000..05c12964cdc0a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/clusterversions.go @@ -0,0 +1,308 @@ +package servicefabric + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ClusterVersionsClient is the service Fabric Management Client +type ClusterVersionsClient struct { + BaseClient +} + +// NewClusterVersionsClient creates an instance of the ClusterVersionsClient client. +func NewClusterVersionsClient(subscriptionID string) ClusterVersionsClient { + return NewClusterVersionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClusterVersionsClientWithBaseURI creates an instance of the ClusterVersionsClient client. +func NewClusterVersionsClientWithBaseURI(baseURI string, subscriptionID string) ClusterVersionsClient { + return ClusterVersionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets information about an available Service Fabric cluster code version. +// Parameters: +// location - the location for the cluster code versions. This is different from cluster location. +// clusterVersion - the cluster code version. +func (client ClusterVersionsClient) Get(ctx context.Context, location string, clusterVersion string) (result ClusterCodeVersionsListResult, err error) { + req, err := client.GetPreparer(ctx, location, clusterVersion) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ClusterVersionsClient) GetPreparer(ctx context.Context, location string, clusterVersion string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterVersion": autorest.Encode("path", clusterVersion), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/clusterVersions/{clusterVersion}", 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 ClusterVersionsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ClusterVersionsClient) GetResponder(resp *http.Response) (result ClusterCodeVersionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByEnvironment gets information about an available Service Fabric cluster code version by environment. +// Parameters: +// location - the location for the cluster code versions. This is different from cluster location. +// environment - the operating system of the cluster. The default means all. +// clusterVersion - the cluster code version. +func (client ClusterVersionsClient) GetByEnvironment(ctx context.Context, location string, environment string, clusterVersion string) (result ClusterCodeVersionsListResult, err error) { + req, err := client.GetByEnvironmentPreparer(ctx, location, environment, clusterVersion) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "GetByEnvironment", nil, "Failure preparing request") + return + } + + resp, err := client.GetByEnvironmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "GetByEnvironment", resp, "Failure sending request") + return + } + + result, err = client.GetByEnvironmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "GetByEnvironment", resp, "Failure responding to request") + } + + return +} + +// GetByEnvironmentPreparer prepares the GetByEnvironment request. +func (client ClusterVersionsClient) GetByEnvironmentPreparer(ctx context.Context, location string, environment string, clusterVersion string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterVersion": autorest.Encode("path", clusterVersion), + "environment": autorest.Encode("path", environment), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/environments/{environment}/clusterVersions/{clusterVersion}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByEnvironmentSender sends the GetByEnvironment request. The method will close the +// http.Response Body if it receives an error. +func (client ClusterVersionsClient) GetByEnvironmentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByEnvironmentResponder handles the response to the GetByEnvironment request. The method always +// closes the http.Response Body. +func (client ClusterVersionsClient) GetByEnvironmentResponder(resp *http.Response) (result ClusterCodeVersionsListResult, 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 all available code versions for Service Fabric cluster resources by location. +// Parameters: +// location - the location for the cluster code versions. This is different from cluster location. +func (client ClusterVersionsClient) List(ctx context.Context, location string) (result ClusterCodeVersionsListResult, err error) { + req, err := client.ListPreparer(ctx, location) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ClusterVersionsClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/clusterVersions", 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 ClusterVersionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ClusterVersionsClient) ListResponder(resp *http.Response) (result ClusterCodeVersionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByEnvironment gets all available code versions for Service Fabric cluster resources by environment. +// Parameters: +// location - the location for the cluster code versions. This is different from cluster location. +// environment - the operating system of the cluster. The default means all. +func (client ClusterVersionsClient) ListByEnvironment(ctx context.Context, location string, environment string) (result ClusterCodeVersionsListResult, err error) { + req, err := client.ListByEnvironmentPreparer(ctx, location, environment) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "ListByEnvironment", nil, "Failure preparing request") + return + } + + resp, err := client.ListByEnvironmentSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "ListByEnvironment", resp, "Failure sending request") + return + } + + result, err = client.ListByEnvironmentResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClusterVersionsClient", "ListByEnvironment", resp, "Failure responding to request") + } + + return +} + +// ListByEnvironmentPreparer prepares the ListByEnvironment request. +func (client ClusterVersionsClient) ListByEnvironmentPreparer(ctx context.Context, location string, environment string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "environment": autorest.Encode("path", environment), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-02-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/environments/{environment}/clusterVersions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByEnvironmentSender sends the ListByEnvironment request. The method will close the +// http.Response Body if it receives an error. +func (client ClusterVersionsClient) ListByEnvironmentSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByEnvironmentResponder handles the response to the ListByEnvironment request. The method always +// closes the http.Response Body. +func (client ClusterVersionsClient) ListByEnvironmentResponder(resp *http.Response) (result ClusterCodeVersionsListResult, 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/servicefabric/mgmt/2018-02-01/servicefabric/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/models.go new file mode 100644 index 0000000000000..1bef986368c89 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/models.go @@ -0,0 +1,3982 @@ +package servicefabric + +// 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 ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// ClusterState enumerates the values for cluster state. +type ClusterState string + +const ( + // AutoScale ... + AutoScale ClusterState = "AutoScale" + // BaselineUpgrade ... + BaselineUpgrade ClusterState = "BaselineUpgrade" + // Deploying ... + Deploying ClusterState = "Deploying" + // EnforcingClusterVersion ... + EnforcingClusterVersion ClusterState = "EnforcingClusterVersion" + // Ready ... + Ready ClusterState = "Ready" + // UpdatingInfrastructure ... + UpdatingInfrastructure ClusterState = "UpdatingInfrastructure" + // UpdatingUserCertificate ... + UpdatingUserCertificate ClusterState = "UpdatingUserCertificate" + // UpdatingUserConfiguration ... + UpdatingUserConfiguration ClusterState = "UpdatingUserConfiguration" + // UpgradeServiceUnreachable ... + UpgradeServiceUnreachable ClusterState = "UpgradeServiceUnreachable" + // WaitingForNodes ... + WaitingForNodes ClusterState = "WaitingForNodes" +) + +// PossibleClusterStateValues returns an array of possible values for the ClusterState const type. +func PossibleClusterStateValues() []ClusterState { + return []ClusterState{AutoScale, BaselineUpgrade, Deploying, EnforcingClusterVersion, Ready, UpdatingInfrastructure, UpdatingUserCertificate, UpdatingUserConfiguration, UpgradeServiceUnreachable, WaitingForNodes} +} + +// DurabilityLevel enumerates the values for durability level. +type DurabilityLevel string + +const ( + // Bronze ... + Bronze DurabilityLevel = "Bronze" + // Gold ... + Gold DurabilityLevel = "Gold" + // Silver ... + Silver DurabilityLevel = "Silver" +) + +// PossibleDurabilityLevelValues returns an array of possible values for the DurabilityLevel const type. +func PossibleDurabilityLevelValues() []DurabilityLevel { + return []DurabilityLevel{Bronze, Gold, Silver} +} + +// Environment enumerates the values for environment. +type Environment string + +const ( + // Linux ... + Linux Environment = "Linux" + // Windows ... + Windows Environment = "Windows" +) + +// PossibleEnvironmentValues returns an array of possible values for the Environment const type. +func PossibleEnvironmentValues() []Environment { + return []Environment{Linux, Windows} +} + +// MoveCost enumerates the values for move cost. +type MoveCost string + +const ( + // High Specifies the move cost of the service as High. The value is 3. + High MoveCost = "High" + // Low Specifies the move cost of the service as Low. The value is 1. + Low MoveCost = "Low" + // Medium Specifies the move cost of the service as Medium. The value is 2. + Medium MoveCost = "Medium" + // Zero Zero move cost. This value is zero. + Zero MoveCost = "Zero" +) + +// PossibleMoveCostValues returns an array of possible values for the MoveCost const type. +func PossibleMoveCostValues() []MoveCost { + return []MoveCost{High, Low, Medium, Zero} +} + +// PartitionScheme enumerates the values for partition scheme. +type PartitionScheme string + +const ( + // Invalid Indicates the partition kind is invalid. All Service Fabric enumerations have the invalid type. + // The value is zero. + Invalid PartitionScheme = "Invalid" + // Named Indicates that the partition is based on string names, and is a NamedPartitionSchemeDescription + // object. The value is 3 + Named PartitionScheme = "Named" + // Singleton Indicates that the partition is based on string names, and is a + // SingletonPartitionSchemeDescription object, The value is 1. + Singleton PartitionScheme = "Singleton" + // UniformInt64Range Indicates that the partition is based on Int64 key ranges, and is a + // UniformInt64RangePartitionSchemeDescription object. The value is 2. + UniformInt64Range PartitionScheme = "UniformInt64Range" +) + +// PossiblePartitionSchemeValues returns an array of possible values for the PartitionScheme const type. +func PossiblePartitionSchemeValues() []PartitionScheme { + return []PartitionScheme{Invalid, Named, Singleton, UniformInt64Range} +} + +// PartitionSchemeBasicPartitionSchemeDescription enumerates the values for partition scheme basic partition +// scheme description. +type PartitionSchemeBasicPartitionSchemeDescription string + +const ( + // PartitionSchemeNamed ... + PartitionSchemeNamed PartitionSchemeBasicPartitionSchemeDescription = "Named" + // PartitionSchemePartitionSchemeDescription ... + PartitionSchemePartitionSchemeDescription PartitionSchemeBasicPartitionSchemeDescription = "PartitionSchemeDescription" + // PartitionSchemeSingleton ... + PartitionSchemeSingleton PartitionSchemeBasicPartitionSchemeDescription = "Singleton" + // PartitionSchemeUniformInt64Range ... + PartitionSchemeUniformInt64Range PartitionSchemeBasicPartitionSchemeDescription = "UniformInt64Range" +) + +// PossiblePartitionSchemeBasicPartitionSchemeDescriptionValues returns an array of possible values for the PartitionSchemeBasicPartitionSchemeDescription const type. +func PossiblePartitionSchemeBasicPartitionSchemeDescriptionValues() []PartitionSchemeBasicPartitionSchemeDescription { + return []PartitionSchemeBasicPartitionSchemeDescription{PartitionSchemeNamed, PartitionSchemePartitionSchemeDescription, PartitionSchemeSingleton, PartitionSchemeUniformInt64Range} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Canceled ... + Canceled ProvisioningState = "Canceled" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Canceled, Failed, Succeeded, Updating} +} + +// ReliabilityLevel enumerates the values for reliability level. +type ReliabilityLevel string + +const ( + // ReliabilityLevelBronze ... + ReliabilityLevelBronze ReliabilityLevel = "Bronze" + // ReliabilityLevelGold ... + ReliabilityLevelGold ReliabilityLevel = "Gold" + // ReliabilityLevelNone ... + ReliabilityLevelNone ReliabilityLevel = "None" + // ReliabilityLevelPlatinum ... + ReliabilityLevelPlatinum ReliabilityLevel = "Platinum" + // ReliabilityLevelSilver ... + ReliabilityLevelSilver ReliabilityLevel = "Silver" +) + +// PossibleReliabilityLevelValues returns an array of possible values for the ReliabilityLevel const type. +func PossibleReliabilityLevelValues() []ReliabilityLevel { + return []ReliabilityLevel{ReliabilityLevelBronze, ReliabilityLevelGold, ReliabilityLevelNone, ReliabilityLevelPlatinum, ReliabilityLevelSilver} +} + +// ReliabilityLevel1 enumerates the values for reliability level 1. +type ReliabilityLevel1 string + +const ( + // ReliabilityLevel1Bronze ... + ReliabilityLevel1Bronze ReliabilityLevel1 = "Bronze" + // ReliabilityLevel1Gold ... + ReliabilityLevel1Gold ReliabilityLevel1 = "Gold" + // ReliabilityLevel1None ... + ReliabilityLevel1None ReliabilityLevel1 = "None" + // ReliabilityLevel1Platinum ... + ReliabilityLevel1Platinum ReliabilityLevel1 = "Platinum" + // ReliabilityLevel1Silver ... + ReliabilityLevel1Silver ReliabilityLevel1 = "Silver" +) + +// PossibleReliabilityLevel1Values returns an array of possible values for the ReliabilityLevel1 const type. +func PossibleReliabilityLevel1Values() []ReliabilityLevel1 { + return []ReliabilityLevel1{ReliabilityLevel1Bronze, ReliabilityLevel1Gold, ReliabilityLevel1None, ReliabilityLevel1Platinum, ReliabilityLevel1Silver} +} + +// ServiceCorrelationScheme enumerates the values for service correlation scheme. +type ServiceCorrelationScheme string + +const ( + // ServiceCorrelationSchemeAffinity Indicates that this service has an affinity relationship with another + // service. Provided for backwards compatibility, consider preferring the Aligned or NonAlignedAffinity + // options. The value is 1. + ServiceCorrelationSchemeAffinity ServiceCorrelationScheme = "Affinity" + // ServiceCorrelationSchemeAlignedAffinity Aligned affinity ensures that the primaries of the partitions of + // the affinitized services are collocated on the same nodes. This is the default and is the same as + // selecting the Affinity scheme. The value is 2. + ServiceCorrelationSchemeAlignedAffinity ServiceCorrelationScheme = "AlignedAffinity" + // ServiceCorrelationSchemeInvalid An invalid correlation scheme. Cannot be used. The value is zero. + ServiceCorrelationSchemeInvalid ServiceCorrelationScheme = "Invalid" + // ServiceCorrelationSchemeNonAlignedAffinity Non-Aligned affinity guarantees that all replicas of each + // service will be placed on the same nodes. Unlike Aligned Affinity, this does not guarantee that replicas + // of particular role will be collocated. The value is 3. + ServiceCorrelationSchemeNonAlignedAffinity ServiceCorrelationScheme = "NonAlignedAffinity" +) + +// PossibleServiceCorrelationSchemeValues returns an array of possible values for the ServiceCorrelationScheme const type. +func PossibleServiceCorrelationSchemeValues() []ServiceCorrelationScheme { + return []ServiceCorrelationScheme{ServiceCorrelationSchemeAffinity, ServiceCorrelationSchemeAlignedAffinity, ServiceCorrelationSchemeInvalid, ServiceCorrelationSchemeNonAlignedAffinity} +} + +// ServiceKind enumerates the values for service kind. +type ServiceKind string + +const ( + // ServiceKindInvalid Indicates the service kind is invalid. All Service Fabric enumerations have the + // invalid type. The value is zero. + ServiceKindInvalid ServiceKind = "Invalid" + // ServiceKindStateful Uses Service Fabric to make its state or part of its state highly available and + // reliable. The value is 2. + ServiceKindStateful ServiceKind = "Stateful" + // ServiceKindStateless Does not use Service Fabric to make its state highly available or reliable. The + // value is 1. + ServiceKindStateless ServiceKind = "Stateless" +) + +// PossibleServiceKindValues returns an array of possible values for the ServiceKind const type. +func PossibleServiceKindValues() []ServiceKind { + return []ServiceKind{ServiceKindInvalid, ServiceKindStateful, ServiceKindStateless} +} + +// ServiceKindBasicServiceResourceProperties enumerates the values for service kind basic service resource +// properties. +type ServiceKindBasicServiceResourceProperties string + +const ( + // ServiceKindServiceResourceProperties ... + ServiceKindServiceResourceProperties ServiceKindBasicServiceResourceProperties = "ServiceResourceProperties" + // ServiceKindStateful1 ... + ServiceKindStateful1 ServiceKindBasicServiceResourceProperties = "Stateful" + // ServiceKindStateless1 ... + ServiceKindStateless1 ServiceKindBasicServiceResourceProperties = "Stateless" +) + +// PossibleServiceKindBasicServiceResourcePropertiesValues returns an array of possible values for the ServiceKindBasicServiceResourceProperties const type. +func PossibleServiceKindBasicServiceResourcePropertiesValues() []ServiceKindBasicServiceResourceProperties { + return []ServiceKindBasicServiceResourceProperties{ServiceKindServiceResourceProperties, ServiceKindStateful1, ServiceKindStateless1} +} + +// ServiceKindBasicServiceResourceUpdateProperties enumerates the values for service kind basic service +// resource update properties. +type ServiceKindBasicServiceResourceUpdateProperties string + +const ( + // ServiceKindBasicServiceResourceUpdatePropertiesServiceKindServiceResourceUpdateProperties ... + ServiceKindBasicServiceResourceUpdatePropertiesServiceKindServiceResourceUpdateProperties ServiceKindBasicServiceResourceUpdateProperties = "ServiceResourceUpdateProperties" + // ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateful ... + ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateful ServiceKindBasicServiceResourceUpdateProperties = "Stateful" + // ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateless ... + ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateless ServiceKindBasicServiceResourceUpdateProperties = "Stateless" +) + +// PossibleServiceKindBasicServiceResourceUpdatePropertiesValues returns an array of possible values for the ServiceKindBasicServiceResourceUpdateProperties const type. +func PossibleServiceKindBasicServiceResourceUpdatePropertiesValues() []ServiceKindBasicServiceResourceUpdateProperties { + return []ServiceKindBasicServiceResourceUpdateProperties{ServiceKindBasicServiceResourceUpdatePropertiesServiceKindServiceResourceUpdateProperties, ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateful, ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateless} +} + +// ServiceLoadMetricWeight enumerates the values for service load metric weight. +type ServiceLoadMetricWeight string + +const ( + // ServiceLoadMetricWeightHigh Specifies the metric weight of the service load as High. The value is 3. + ServiceLoadMetricWeightHigh ServiceLoadMetricWeight = "High" + // ServiceLoadMetricWeightLow Specifies the metric weight of the service load as Low. The value is 1. + ServiceLoadMetricWeightLow ServiceLoadMetricWeight = "Low" + // ServiceLoadMetricWeightMedium Specifies the metric weight of the service load as Medium. The value is 2. + ServiceLoadMetricWeightMedium ServiceLoadMetricWeight = "Medium" + // ServiceLoadMetricWeightZero Disables resource balancing for this metric. This value is zero. + ServiceLoadMetricWeightZero ServiceLoadMetricWeight = "Zero" +) + +// PossibleServiceLoadMetricWeightValues returns an array of possible values for the ServiceLoadMetricWeight const type. +func PossibleServiceLoadMetricWeightValues() []ServiceLoadMetricWeight { + return []ServiceLoadMetricWeight{ServiceLoadMetricWeightHigh, ServiceLoadMetricWeightLow, ServiceLoadMetricWeightMedium, ServiceLoadMetricWeightZero} +} + +// ServicePlacementPolicyType enumerates the values for service placement policy type. +type ServicePlacementPolicyType string + +const ( + // ServicePlacementPolicyTypeInvalid Indicates the type of the placement policy is invalid. All Service + // Fabric enumerations have the invalid type. The value is zero. + ServicePlacementPolicyTypeInvalid ServicePlacementPolicyType = "Invalid" + // ServicePlacementPolicyTypeInvalidDomain Indicates that the ServicePlacementPolicyDescription is of type + // ServicePlacementInvalidDomainPolicyDescription, which indicates that a particular fault or upgrade + // domain cannot be used for placement of this service. The value is 1. + ServicePlacementPolicyTypeInvalidDomain ServicePlacementPolicyType = "InvalidDomain" + // ServicePlacementPolicyTypeNonPartiallyPlaceService Indicates that the ServicePlacementPolicyDescription + // is of type ServicePlacementNonPartiallyPlaceServicePolicyDescription, which indicates that if possible + // all replicas of a particular partition of the service should be placed atomically. The value is 5. + ServicePlacementPolicyTypeNonPartiallyPlaceService ServicePlacementPolicyType = "NonPartiallyPlaceService" + // ServicePlacementPolicyTypePreferredPrimaryDomain Indicates that the ServicePlacementPolicyDescription is + // of type ServicePlacementPreferPrimaryDomainPolicyDescription, which indicates that if possible the + // Primary replica for the partitions of the service should be located in a particular domain as an + // optimization. The value is 3. + ServicePlacementPolicyTypePreferredPrimaryDomain ServicePlacementPolicyType = "PreferredPrimaryDomain" + // ServicePlacementPolicyTypeRequiredDomain Indicates that the ServicePlacementPolicyDescription is of type + // ServicePlacementRequireDomainDistributionPolicyDescription indicating that the replicas of the service + // must be placed in a specific domain. The value is 2. + ServicePlacementPolicyTypeRequiredDomain ServicePlacementPolicyType = "RequiredDomain" + // ServicePlacementPolicyTypeRequiredDomainDistribution Indicates that the + // ServicePlacementPolicyDescription is of type ServicePlacementRequireDomainDistributionPolicyDescription, + // indicating that the system will disallow placement of any two replicas from the same partition in the + // same domain at any time. The value is 4. + ServicePlacementPolicyTypeRequiredDomainDistribution ServicePlacementPolicyType = "RequiredDomainDistribution" +) + +// PossibleServicePlacementPolicyTypeValues returns an array of possible values for the ServicePlacementPolicyType const type. +func PossibleServicePlacementPolicyTypeValues() []ServicePlacementPolicyType { + return []ServicePlacementPolicyType{ServicePlacementPolicyTypeInvalid, ServicePlacementPolicyTypeInvalidDomain, ServicePlacementPolicyTypeNonPartiallyPlaceService, ServicePlacementPolicyTypePreferredPrimaryDomain, ServicePlacementPolicyTypeRequiredDomain, ServicePlacementPolicyTypeRequiredDomainDistribution} +} + +// Type enumerates the values for type. +type Type string + +const ( + // TypeServicePlacementPolicyDescription ... + TypeServicePlacementPolicyDescription Type = "ServicePlacementPolicyDescription" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{TypeServicePlacementPolicyDescription} +} + +// UpgradeMode enumerates the values for upgrade mode. +type UpgradeMode string + +const ( + // Automatic ... + Automatic UpgradeMode = "Automatic" + // Manual ... + Manual UpgradeMode = "Manual" +) + +// PossibleUpgradeModeValues returns an array of possible values for the UpgradeMode const type. +func PossibleUpgradeModeValues() []UpgradeMode { + return []UpgradeMode{Automatic, Manual} +} + +// UpgradeMode1 enumerates the values for upgrade mode 1. +type UpgradeMode1 string + +const ( + // UpgradeMode1Automatic ... + UpgradeMode1Automatic UpgradeMode1 = "Automatic" + // UpgradeMode1Manual ... + UpgradeMode1Manual UpgradeMode1 = "Manual" +) + +// PossibleUpgradeMode1Values returns an array of possible values for the UpgradeMode1 const type. +func PossibleUpgradeMode1Values() []UpgradeMode1 { + return []UpgradeMode1{UpgradeMode1Automatic, UpgradeMode1Manual} +} + +// X509StoreName enumerates the values for x509 store name. +type X509StoreName string + +const ( + // AddressBook ... + AddressBook X509StoreName = "AddressBook" + // AuthRoot ... + AuthRoot X509StoreName = "AuthRoot" + // CertificateAuthority ... + CertificateAuthority X509StoreName = "CertificateAuthority" + // Disallowed ... + Disallowed X509StoreName = "Disallowed" + // My ... + My X509StoreName = "My" + // Root ... + Root X509StoreName = "Root" + // TrustedPeople ... + TrustedPeople X509StoreName = "TrustedPeople" + // TrustedPublisher ... + TrustedPublisher X509StoreName = "TrustedPublisher" +) + +// PossibleX509StoreNameValues returns an array of possible values for the X509StoreName const type. +func PossibleX509StoreNameValues() []X509StoreName { + return []X509StoreName{AddressBook, AuthRoot, CertificateAuthority, Disallowed, My, Root, TrustedPeople, TrustedPublisher} +} + +// X509StoreName1 enumerates the values for x509 store name 1. +type X509StoreName1 string + +const ( + // X509StoreName1AddressBook ... + X509StoreName1AddressBook X509StoreName1 = "AddressBook" + // X509StoreName1AuthRoot ... + X509StoreName1AuthRoot X509StoreName1 = "AuthRoot" + // X509StoreName1CertificateAuthority ... + X509StoreName1CertificateAuthority X509StoreName1 = "CertificateAuthority" + // X509StoreName1Disallowed ... + X509StoreName1Disallowed X509StoreName1 = "Disallowed" + // X509StoreName1My ... + X509StoreName1My X509StoreName1 = "My" + // X509StoreName1Root ... + X509StoreName1Root X509StoreName1 = "Root" + // X509StoreName1TrustedPeople ... + X509StoreName1TrustedPeople X509StoreName1 = "TrustedPeople" + // X509StoreName1TrustedPublisher ... + X509StoreName1TrustedPublisher X509StoreName1 = "TrustedPublisher" +) + +// PossibleX509StoreName1Values returns an array of possible values for the X509StoreName1 const type. +func PossibleX509StoreName1Values() []X509StoreName1 { + return []X509StoreName1{X509StoreName1AddressBook, X509StoreName1AuthRoot, X509StoreName1CertificateAuthority, X509StoreName1Disallowed, X509StoreName1My, X509StoreName1Root, X509StoreName1TrustedPeople, X509StoreName1TrustedPublisher} +} + +// ApplicationDeltaHealthPolicy defines a delta health policy used to evaluate the health of an application or one +// of its child entities when upgrading the cluster. +type ApplicationDeltaHealthPolicy struct { + // DefaultServiceTypeDeltaHealthPolicy - The delta health policy used by default to evaluate the health of a service type when upgrading the cluster. + DefaultServiceTypeDeltaHealthPolicy *ServiceTypeDeltaHealthPolicy `json:"defaultServiceTypeDeltaHealthPolicy,omitempty"` + // ServiceTypeDeltaHealthPolicies - The map with service type delta health policy per service type name. The map is empty by default. + ServiceTypeDeltaHealthPolicies map[string]*ServiceTypeDeltaHealthPolicy `json:"serviceTypeDeltaHealthPolicies"` +} + +// MarshalJSON is the custom marshaler for ApplicationDeltaHealthPolicy. +func (adhp ApplicationDeltaHealthPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if adhp.DefaultServiceTypeDeltaHealthPolicy != nil { + objectMap["defaultServiceTypeDeltaHealthPolicy"] = adhp.DefaultServiceTypeDeltaHealthPolicy + } + if adhp.ServiceTypeDeltaHealthPolicies != nil { + objectMap["serviceTypeDeltaHealthPolicies"] = adhp.ServiceTypeDeltaHealthPolicies + } + return json.Marshal(objectMap) +} + +// ApplicationHealthPolicy defines a health policy used to evaluate the health of an application or one of its +// children entities. +type ApplicationHealthPolicy struct { + // DefaultServiceTypeHealthPolicy - The health policy used by default to evaluate the health of a service type. + DefaultServiceTypeHealthPolicy *ServiceTypeHealthPolicy `json:"defaultServiceTypeHealthPolicy,omitempty"` + // ServiceTypeHealthPolicies - The map with service type health policy per service type name. The map is empty by default. + ServiceTypeHealthPolicies map[string]*ServiceTypeHealthPolicy `json:"serviceTypeHealthPolicies"` + // ConsiderWarningAsError - Indicates whether warnings are treated with the same severity as errors. + ConsiderWarningAsError *bool `json:"ConsiderWarningAsError,omitempty"` + // MaxPercentUnhealthyDeployedApplications - The maximum allowed percentage of unhealthy deployed applications. Allowed values are Byte values from zero to 100. + // The percentage represents the maximum tolerated percentage of deployed applications that can be unhealthy before the application is considered in error. + // This is calculated by dividing the number of unhealthy deployed applications over the number of nodes where the application is currently deployed on in the cluster. + // The computation rounds up to tolerate one failure on small numbers of nodes. Default percentage is zero. + MaxPercentUnhealthyDeployedApplications *int32 `json:"MaxPercentUnhealthyDeployedApplications,omitempty"` + // DefaultServiceTypeHealthPolicy1 - The health policy used by default to evaluate the health of a service type. + DefaultServiceTypeHealthPolicy1 *ServiceTypeHealthPolicy `json:"DefaultServiceTypeHealthPolicy,omitempty"` + // ServiceTypeHealthPolicyMap - The map with service type health policy per service type name. The map is empty by default. + ServiceTypeHealthPolicyMap map[string]*ServiceTypeHealthPolicy `json:"ServiceTypeHealthPolicyMap"` +} + +// MarshalJSON is the custom marshaler for ApplicationHealthPolicy. +func (ahp ApplicationHealthPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ahp.DefaultServiceTypeHealthPolicy != nil { + objectMap["defaultServiceTypeHealthPolicy"] = ahp.DefaultServiceTypeHealthPolicy + } + if ahp.ServiceTypeHealthPolicies != nil { + objectMap["serviceTypeHealthPolicies"] = ahp.ServiceTypeHealthPolicies + } + if ahp.ConsiderWarningAsError != nil { + objectMap["ConsiderWarningAsError"] = ahp.ConsiderWarningAsError + } + if ahp.MaxPercentUnhealthyDeployedApplications != nil { + objectMap["MaxPercentUnhealthyDeployedApplications"] = ahp.MaxPercentUnhealthyDeployedApplications + } + if ahp.DefaultServiceTypeHealthPolicy1 != nil { + objectMap["DefaultServiceTypeHealthPolicy"] = ahp.DefaultServiceTypeHealthPolicy1 + } + if ahp.ServiceTypeHealthPolicyMap != nil { + objectMap["ServiceTypeHealthPolicyMap"] = ahp.ServiceTypeHealthPolicyMap + } + return json.Marshal(objectMap) +} + +// ApplicationMetricDescription describes capacity information for a custom resource balancing metric. This can be +// used to limit the total consumption of this metric by the services of this application. +type ApplicationMetricDescription struct { + // Name - The name of the metric. + Name *string `json:"Name,omitempty"` + // MaximumCapacity - The maximum node capacity for Service Fabric application. + // This is the maximum Load for an instance of this application on a single node. Even if the capacity of node is greater than this value, Service Fabric will limit the total load of services within the application on each node to this value. + // If set to zero, capacity for this metric is unlimited on each node. + // When creating a new application with application capacity defined, the product of MaximumNodes and this value must always be smaller than or equal to TotalApplicationCapacity. + // When updating existing application with application capacity, the product of MaximumNodes and this value must always be smaller than or equal to TotalApplicationCapacity. + MaximumCapacity *int64 `json:"MaximumCapacity,omitempty"` + // ReservationCapacity - The node reservation capacity for Service Fabric application. + // This is the amount of load which is reserved on nodes which have instances of this application. + // If MinimumNodes is specified, then the product of these values will be the capacity reserved in the cluster for the application. + // If set to zero, no capacity is reserved for this metric. + // When setting application capacity or when updating application capacity; this value must be smaller than or equal to MaximumCapacity for each metric. + ReservationCapacity *int64 `json:"ReservationCapacity,omitempty"` + // TotalApplicationCapacity - The total metric capacity for Service Fabric application. + // This is the total metric capacity for this application in the cluster. Service Fabric will try to limit the sum of loads of services within the application to this value. + // When creating a new application with application capacity defined, the product of MaximumNodes and MaximumCapacity must always be smaller than or equal to this value. + TotalApplicationCapacity *int64 `json:"TotalApplicationCapacity,omitempty"` +} + +// ApplicationResource the application resource. +type ApplicationResource struct { + autorest.Response `json:"-"` + // ApplicationResourceProperties - The application resource properties. + *ApplicationResourceProperties `json:"properties,omitempty"` + // ID - Azure resource identifier. + ID *string `json:"id,omitempty"` + // Name - Azure resource name. + Name *string `json:"name,omitempty"` + // Type - Azure resource type. + Type *string `json:"type,omitempty"` + // Location - Azure resource location. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationResource. +func (ar ApplicationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ar.ApplicationResourceProperties != nil { + objectMap["properties"] = ar.ApplicationResourceProperties + } + if ar.ID != nil { + objectMap["id"] = ar.ID + } + if ar.Name != nil { + objectMap["name"] = ar.Name + } + if ar.Type != nil { + objectMap["type"] = ar.Type + } + if ar.Location != nil { + objectMap["location"] = ar.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationResource struct. +func (ar *ApplicationResource) 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 + } + ar.ApplicationResourceProperties = &applicationResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ar.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ar.Location = &location + } + } + } + + return nil +} + +// ApplicationResourceList the list of application resources. +type ApplicationResourceList struct { + autorest.Response `json:"-"` + Value *[]ApplicationResource `json:"value,omitempty"` +} + +// ApplicationResourceProperties the application resource properties. +type ApplicationResourceProperties struct { + // ProvisioningState - The current deployment or provisioning state, which only appears in the response + ProvisioningState *string `json:"provisioningState,omitempty"` + // TypeName - The application type name as defined in the application manifest. + TypeName *string `json:"typeName,omitempty"` + // TypeVersion - The version of the application type as defined in the application manifest. + TypeVersion *string `json:"typeVersion,omitempty"` + // Parameters - List of application parameters with overridden values from their default values specified in the application manifest. + Parameters map[string]*string `json:"parameters"` + // UpgradePolicy - Describes the policy for a monitored application upgrade. + UpgradePolicy *ApplicationUpgradePolicy `json:"upgradePolicy,omitempty"` + // MinimumNodes - The minimum number of nodes where Service Fabric will reserve capacity for this application. Note that this does not mean that the services of this application will be placed on all of those nodes. If this property is set to zero, no capacity will be reserved. The value of this property cannot be more than the value of the MaximumNodes property. + MinimumNodes *int64 `json:"minimumNodes,omitempty"` + // MaximumNodes - The maximum number of nodes where Service Fabric will reserve capacity for this application. Note that this does not mean that the services of this application will be placed on all of those nodes. By default, the value of this property is zero and it means that the services can be placed on any node. + MaximumNodes *int64 `json:"maximumNodes,omitempty"` + // RemoveApplicationCapacity - Remove the current application capacity settings. + RemoveApplicationCapacity *bool `json:"removeApplicationCapacity,omitempty"` + // Metrics - List of application capacity metric description. + Metrics *[]ApplicationMetricDescription `json:"metrics,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationResourceProperties. +func (arp ApplicationResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arp.ProvisioningState != nil { + objectMap["provisioningState"] = arp.ProvisioningState + } + if arp.TypeName != nil { + objectMap["typeName"] = arp.TypeName + } + if arp.TypeVersion != nil { + objectMap["typeVersion"] = arp.TypeVersion + } + if arp.Parameters != nil { + objectMap["parameters"] = arp.Parameters + } + if arp.UpgradePolicy != nil { + objectMap["upgradePolicy"] = arp.UpgradePolicy + } + if arp.MinimumNodes != nil { + objectMap["minimumNodes"] = arp.MinimumNodes + } + if arp.MaximumNodes != nil { + objectMap["maximumNodes"] = arp.MaximumNodes + } + if arp.RemoveApplicationCapacity != nil { + objectMap["removeApplicationCapacity"] = arp.RemoveApplicationCapacity + } + if arp.Metrics != nil { + objectMap["metrics"] = arp.Metrics + } + return json.Marshal(objectMap) +} + +// ApplicationResourceUpdate the application resource for patch operations. +type ApplicationResourceUpdate struct { + autorest.Response `json:"-"` + // ApplicationResourceUpdateProperties - The application resource properties for patch operations. + *ApplicationResourceUpdateProperties `json:"properties,omitempty"` + // ID - Azure resource identifier. + ID *string `json:"id,omitempty"` + // Name - Azure resource name. + Name *string `json:"name,omitempty"` + // Type - Azure resource type. + Type *string `json:"type,omitempty"` + // Location - Azure resource location. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationResourceUpdate. +func (aru ApplicationResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aru.ApplicationResourceUpdateProperties != nil { + objectMap["properties"] = aru.ApplicationResourceUpdateProperties + } + if aru.ID != nil { + objectMap["id"] = aru.ID + } + if aru.Name != nil { + objectMap["name"] = aru.Name + } + if aru.Type != nil { + objectMap["type"] = aru.Type + } + if aru.Location != nil { + objectMap["location"] = aru.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationResourceUpdate struct. +func (aru *ApplicationResourceUpdate) 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 applicationResourceUpdateProperties ApplicationResourceUpdateProperties + err = json.Unmarshal(*v, &applicationResourceUpdateProperties) + if err != nil { + return err + } + aru.ApplicationResourceUpdateProperties = &applicationResourceUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + aru.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + aru.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + aru.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + aru.Location = &location + } + } + } + + return nil +} + +// ApplicationResourceUpdateProperties the application resource properties for patch operations. +type ApplicationResourceUpdateProperties struct { + // TypeVersion - The version of the application type as defined in the application manifest. + TypeVersion *string `json:"typeVersion,omitempty"` + // Parameters - List of application parameters with overridden values from their default values specified in the application manifest. + Parameters map[string]*string `json:"parameters"` + // UpgradePolicy - Describes the policy for a monitored application upgrade. + UpgradePolicy *ApplicationUpgradePolicy `json:"upgradePolicy,omitempty"` + // MinimumNodes - The minimum number of nodes where Service Fabric will reserve capacity for this application. Note that this does not mean that the services of this application will be placed on all of those nodes. If this property is set to zero, no capacity will be reserved. The value of this property cannot be more than the value of the MaximumNodes property. + MinimumNodes *int64 `json:"minimumNodes,omitempty"` + // MaximumNodes - The maximum number of nodes where Service Fabric will reserve capacity for this application. Note that this does not mean that the services of this application will be placed on all of those nodes. By default, the value of this property is zero and it means that the services can be placed on any node. + MaximumNodes *int64 `json:"maximumNodes,omitempty"` + // RemoveApplicationCapacity - Remove the current application capacity settings. + RemoveApplicationCapacity *bool `json:"removeApplicationCapacity,omitempty"` + // Metrics - List of application capacity metric description. + Metrics *[]ApplicationMetricDescription `json:"metrics,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationResourceUpdateProperties. +func (arup ApplicationResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if arup.TypeVersion != nil { + objectMap["typeVersion"] = arup.TypeVersion + } + if arup.Parameters != nil { + objectMap["parameters"] = arup.Parameters + } + if arup.UpgradePolicy != nil { + objectMap["upgradePolicy"] = arup.UpgradePolicy + } + if arup.MinimumNodes != nil { + objectMap["minimumNodes"] = arup.MinimumNodes + } + if arup.MaximumNodes != nil { + objectMap["maximumNodes"] = arup.MaximumNodes + } + if arup.RemoveApplicationCapacity != nil { + objectMap["removeApplicationCapacity"] = arup.RemoveApplicationCapacity + } + if arup.Metrics != nil { + objectMap["metrics"] = arup.Metrics + } + return json.Marshal(objectMap) +} + +// ApplicationsCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ApplicationsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationsCreateFuture) Result(client ApplicationsClient) (ar ApplicationResource, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ApplicationsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ar.Response.Response, err = future.GetResult(sender); err == nil && ar.Response.Response.StatusCode != http.StatusNoContent { + ar, err = client.CreateResponder(ar.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsCreateFuture", "Result", ar.Response.Response, "Failure responding to request") + } + } + return +} + +// ApplicationsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ApplicationsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationsDeleteFuture) Result(client ApplicationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ApplicationsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ApplicationsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ApplicationsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationsUpdateFuture) Result(client ApplicationsClient) (aru ApplicationResourceUpdate, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ApplicationsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if aru.Response.Response, err = future.GetResult(sender); err == nil && aru.Response.Response.StatusCode != http.StatusNoContent { + aru, err = client.UpdateResponder(aru.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationsUpdateFuture", "Result", aru.Response.Response, "Failure responding to request") + } + } + return +} + +// ApplicationTypeResource the application type name resource +type ApplicationTypeResource struct { + autorest.Response `json:"-"` + // ApplicationTypeResourceProperties - The application type name properties + *ApplicationTypeResourceProperties `json:"properties,omitempty"` + // ID - Azure resource identifier. + ID *string `json:"id,omitempty"` + // Name - Azure resource name. + Name *string `json:"name,omitempty"` + // Type - Azure resource type. + Type *string `json:"type,omitempty"` + // Location - Azure resource location. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationTypeResource. +func (atr ApplicationTypeResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atr.ApplicationTypeResourceProperties != nil { + objectMap["properties"] = atr.ApplicationTypeResourceProperties + } + if atr.ID != nil { + objectMap["id"] = atr.ID + } + if atr.Name != nil { + objectMap["name"] = atr.Name + } + if atr.Type != nil { + objectMap["type"] = atr.Type + } + if atr.Location != nil { + objectMap["location"] = atr.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationTypeResource struct. +func (atr *ApplicationTypeResource) 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 applicationTypeResourceProperties ApplicationTypeResourceProperties + err = json.Unmarshal(*v, &applicationTypeResourceProperties) + if err != nil { + return err + } + atr.ApplicationTypeResourceProperties = &applicationTypeResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + atr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + atr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + atr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + atr.Location = &location + } + } + } + + return nil +} + +// ApplicationTypeResourceList the list of application type names. +type ApplicationTypeResourceList struct { + autorest.Response `json:"-"` + Value *[]ApplicationTypeResource `json:"value,omitempty"` +} + +// ApplicationTypeResourceProperties the application type name properties +type ApplicationTypeResourceProperties struct { + // ProvisioningState - The current deployment or provisioning state, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// ApplicationTypesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ApplicationTypesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationTypesDeleteFuture) Result(client ApplicationTypesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ApplicationTypesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ApplicationTypeVersionResource an application type version resource for the specified application type name +// resource. +type ApplicationTypeVersionResource struct { + autorest.Response `json:"-"` + // ApplicationTypeVersionResourceProperties - The properties of the application type version resource. + *ApplicationTypeVersionResourceProperties `json:"properties,omitempty"` + // ID - Azure resource identifier. + ID *string `json:"id,omitempty"` + // Name - Azure resource name. + Name *string `json:"name,omitempty"` + // Type - Azure resource type. + Type *string `json:"type,omitempty"` + // Location - Azure resource location. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for ApplicationTypeVersionResource. +func (atvr ApplicationTypeVersionResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atvr.ApplicationTypeVersionResourceProperties != nil { + objectMap["properties"] = atvr.ApplicationTypeVersionResourceProperties + } + if atvr.ID != nil { + objectMap["id"] = atvr.ID + } + if atvr.Name != nil { + objectMap["name"] = atvr.Name + } + if atvr.Type != nil { + objectMap["type"] = atvr.Type + } + if atvr.Location != nil { + objectMap["location"] = atvr.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ApplicationTypeVersionResource struct. +func (atvr *ApplicationTypeVersionResource) 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 applicationTypeVersionResourceProperties ApplicationTypeVersionResourceProperties + err = json.Unmarshal(*v, &applicationTypeVersionResourceProperties) + if err != nil { + return err + } + atvr.ApplicationTypeVersionResourceProperties = &applicationTypeVersionResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + atvr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + atvr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + atvr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + atvr.Location = &location + } + } + } + + return nil +} + +// ApplicationTypeVersionResourceList the list of application type version resources for the specified application +// type name resource. +type ApplicationTypeVersionResourceList struct { + autorest.Response `json:"-"` + Value *[]ApplicationTypeVersionResource `json:"value,omitempty"` +} + +// ApplicationTypeVersionResourceProperties the properties of the application type version resource. +type ApplicationTypeVersionResourceProperties struct { + // ProvisioningState - The current deployment or provisioning state, which only appears in the response + ProvisioningState *string `json:"provisioningState,omitempty"` + // AppPackageURL - The URL to the application package + AppPackageURL *string `json:"appPackageUrl,omitempty"` + // DefaultParameterList - List of application type parameters that can be overridden when creating or updating the application. + DefaultParameterList map[string]*string `json:"defaultParameterList"` +} + +// MarshalJSON is the custom marshaler for ApplicationTypeVersionResourceProperties. +func (atvrp ApplicationTypeVersionResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if atvrp.ProvisioningState != nil { + objectMap["provisioningState"] = atvrp.ProvisioningState + } + if atvrp.AppPackageURL != nil { + objectMap["appPackageUrl"] = atvrp.AppPackageURL + } + if atvrp.DefaultParameterList != nil { + objectMap["defaultParameterList"] = atvrp.DefaultParameterList + } + return json.Marshal(objectMap) +} + +// ApplicationTypeVersionsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ApplicationTypeVersionsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationTypeVersionsCreateFuture) Result(client ApplicationTypeVersionsClient) (atvr ApplicationTypeVersionResource, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ApplicationTypeVersionsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if atvr.Response.Response, err = future.GetResult(sender); err == nil && atvr.Response.Response.StatusCode != http.StatusNoContent { + atvr, err = client.CreateResponder(atvr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsCreateFuture", "Result", atvr.Response.Response, "Failure responding to request") + } + } + return +} + +// ApplicationTypeVersionsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ApplicationTypeVersionsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ApplicationTypeVersionsDeleteFuture) Result(client ApplicationTypeVersionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ApplicationTypeVersionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ApplicationTypeVersionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ApplicationUpgradePolicy describes the policy for a monitored application upgrade. +type ApplicationUpgradePolicy struct { + // UpgradeReplicaSetCheckTimeout - The maximum amount of time to block processing of an upgrade domain and prevent loss of availability when there are unexpected issues. When this timeout expires, processing of the upgrade domain will proceed regardless of availability loss issues. The timeout is reset at the start of each upgrade domain. Valid values are between 0 and 42949672925 inclusive. (unsigned 32-bit integer). + UpgradeReplicaSetCheckTimeout *int64 `json:"upgradeReplicaSetCheckTimeout,omitempty"` + // ForceRestart - If true, then processes are forcefully restarted during upgrade even when the code version has not changed (the upgrade only changes configuration or data). + ForceRestart *bool `json:"forceRestart,omitempty"` + // RollingUpgradeMonitoringPolicy - The policy used for monitoring the application upgrade + RollingUpgradeMonitoringPolicy *RollingUpgradeMonitoringPolicy `json:"rollingUpgradeMonitoringPolicy,omitempty"` + // ApplicationHealthPolicy - Defines a health policy used to evaluate the health of an application or one of its children entities. + ApplicationHealthPolicy *ApplicationHealthPolicy `json:"applicationHealthPolicy,omitempty"` +} + +// AvailableOperationDisplay operation supported by Service Fabric resource provider +type AvailableOperationDisplay struct { + // Provider - The name of the provider. + Provider *string `json:"provider,omitempty"` + // Resource - The resource on which the operation is performed + Resource *string `json:"resource,omitempty"` + // Operation - The operation that can be performed. + Operation *string `json:"operation,omitempty"` + // Description - Operation description + Description *string `json:"description,omitempty"` +} + +// AzureActiveDirectory the settings to enable AAD authentication on the cluster. +type AzureActiveDirectory struct { + // TenantID - Azure active directory tenant id. + TenantID *string `json:"tenantId,omitempty"` + // ClusterApplication - Azure active directory cluster application id. + ClusterApplication *string `json:"clusterApplication,omitempty"` + // ClientApplication - Azure active directory client application id. + ClientApplication *string `json:"clientApplication,omitempty"` +} + +// CertificateDescription describes the certificate details. +type CertificateDescription struct { + // Thumbprint - Thumbprint of the primary certificate. + Thumbprint *string `json:"thumbprint,omitempty"` + // ThumbprintSecondary - Thumbprint of the secondary certificate. + ThumbprintSecondary *string `json:"thumbprintSecondary,omitempty"` + // X509StoreName - The local certificate store location. Possible values include: 'AddressBook', 'AuthRoot', 'CertificateAuthority', 'Disallowed', 'My', 'Root', 'TrustedPeople', 'TrustedPublisher' + X509StoreName X509StoreName `json:"x509StoreName,omitempty"` +} + +// ClientCertificateCommonName describes the client certificate details using common name. +type ClientCertificateCommonName struct { + // IsAdmin - Indicates if the client certificate has admin access to the cluster. Non admin clients can perform only read only operations on the cluster. + IsAdmin *bool `json:"isAdmin,omitempty"` + // CertificateCommonName - The common name of the client certificate. + CertificateCommonName *string `json:"certificateCommonName,omitempty"` + // CertificateIssuerThumbprint - The issuer thumbprint of the client certificate. + CertificateIssuerThumbprint *string `json:"certificateIssuerThumbprint,omitempty"` +} + +// ClientCertificateThumbprint describes the client certificate details using thumbprint. +type ClientCertificateThumbprint struct { + // IsAdmin - Indicates if the client certificate has admin access to the cluster. Non admin clients can perform only read only operations on the cluster. + IsAdmin *bool `json:"isAdmin,omitempty"` + // CertificateThumbprint - The thumbprint of the client certificate. + CertificateThumbprint *string `json:"certificateThumbprint,omitempty"` +} + +// Cluster the cluster resource +type Cluster struct { + autorest.Response `json:"-"` + // ClusterProperties - The cluster resource properties + *ClusterProperties `json:"properties,omitempty"` + // ID - Azure resource identifier. + ID *string `json:"id,omitempty"` + // Name - Azure resource name. + Name *string `json:"name,omitempty"` + // Type - Azure resource type. + Type *string `json:"type,omitempty"` + // Location - Azure resource location. + Location *string `json:"location,omitempty"` + // Tags - Azure resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Cluster. +func (c Cluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.ClusterProperties != nil { + objectMap["properties"] = c.ClusterProperties + } + if c.ID != nil { + objectMap["id"] = c.ID + } + if c.Name != nil { + objectMap["name"] = c.Name + } + if c.Type != nil { + objectMap["type"] = c.Type + } + if c.Location != nil { + objectMap["location"] = c.Location + } + if c.Tags != nil { + objectMap["tags"] = c.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Cluster struct. +func (c *Cluster) 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 clusterProperties ClusterProperties + err = json.Unmarshal(*v, &clusterProperties) + if err != nil { + return err + } + c.ClusterProperties = &clusterProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + c.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + c.Tags = tags + } + } + } + + return nil +} + +// ClusterCodeVersionsListResult the list results of the ServiceFabric runtime versions. +type ClusterCodeVersionsListResult struct { + autorest.Response `json:"-"` + Value *[]ClusterCodeVersionsResult `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ClusterCodeVersionsResult the result of the ServiceFabric runtime versions +type ClusterCodeVersionsResult struct { + // ID - The identification of the result + ID *string `json:"id,omitempty"` + // Name - The name of the result + Name *string `json:"name,omitempty"` + // Type - The result resource type + Type *string `json:"type,omitempty"` + // ClusterVersionDetails - The detail of the Service Fabric runtime version result + *ClusterVersionDetails `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterCodeVersionsResult. +func (ccvr ClusterCodeVersionsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ccvr.ID != nil { + objectMap["id"] = ccvr.ID + } + if ccvr.Name != nil { + objectMap["name"] = ccvr.Name + } + if ccvr.Type != nil { + objectMap["type"] = ccvr.Type + } + if ccvr.ClusterVersionDetails != nil { + objectMap["properties"] = ccvr.ClusterVersionDetails + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ClusterCodeVersionsResult struct. +func (ccvr *ClusterCodeVersionsResult) 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 "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ccvr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ccvr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ccvr.Type = &typeVar + } + case "properties": + if v != nil { + var clusterVersionDetails ClusterVersionDetails + err = json.Unmarshal(*v, &clusterVersionDetails) + if err != nil { + return err + } + ccvr.ClusterVersionDetails = &clusterVersionDetails + } + } + } + + return nil +} + +// ClusterHealthPolicy defines a health policy used to evaluate the health of the cluster or of a cluster node. +type ClusterHealthPolicy struct { + // MaxPercentUnhealthyNodes - The maximum allowed percentage of unhealthy nodes before reporting an error. For example, to allow 10% of nodes to be unhealthy, this value would be 10. + // The percentage represents the maximum tolerated percentage of nodes that can be unhealthy before the cluster is considered in error. + // If the percentage is respected but there is at least one unhealthy node, the health is evaluated as Warning. + // The percentage is calculated by dividing the number of unhealthy nodes over the total number of nodes in the cluster. + // The computation rounds up to tolerate one failure on small numbers of nodes. Default percentage is zero. + // In large clusters, some nodes will always be down or out for repairs, so this percentage should be configured to tolerate that. + MaxPercentUnhealthyNodes *int32 `json:"maxPercentUnhealthyNodes,omitempty"` + // MaxPercentUnhealthyApplications - The maximum allowed percentage of unhealthy applications before reporting an error. For example, to allow 10% of applications to be unhealthy, this value would be 10. + // The percentage represents the maximum tolerated percentage of applications that can be unhealthy before the cluster is considered in error. + // If the percentage is respected but there is at least one unhealthy application, the health is evaluated as Warning. + // This is calculated by dividing the number of unhealthy applications over the total number of application instances in the cluster, excluding applications of application types that are included in the ApplicationTypeHealthPolicyMap. + // The computation rounds up to tolerate one failure on small numbers of applications. Default percentage is zero. + MaxPercentUnhealthyApplications *int32 `json:"maxPercentUnhealthyApplications,omitempty"` + // ApplicationHealthPolicies - Defines the application health policy map used to evaluate the health of an application or one of its children entities. + ApplicationHealthPolicies map[string]*ApplicationHealthPolicy `json:"applicationHealthPolicies"` +} + +// MarshalJSON is the custom marshaler for ClusterHealthPolicy. +func (chp ClusterHealthPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if chp.MaxPercentUnhealthyNodes != nil { + objectMap["maxPercentUnhealthyNodes"] = chp.MaxPercentUnhealthyNodes + } + if chp.MaxPercentUnhealthyApplications != nil { + objectMap["maxPercentUnhealthyApplications"] = chp.MaxPercentUnhealthyApplications + } + if chp.ApplicationHealthPolicies != nil { + objectMap["applicationHealthPolicies"] = chp.ApplicationHealthPolicies + } + return json.Marshal(objectMap) +} + +// ClusterListResult cluster list results +type ClusterListResult struct { + autorest.Response `json:"-"` + Value *[]Cluster `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ClusterProperties describes the cluster resource properties. +type ClusterProperties struct { + // AddOnFeatures - The list of add-on features to enable in the cluster. + AddOnFeatures *[]string `json:"addOnFeatures,omitempty"` + // AvailableClusterVersions - The Service Fabric runtime versions available for this cluster. + AvailableClusterVersions *[]ClusterVersionDetails `json:"availableClusterVersions,omitempty"` + // AzureActiveDirectory - The AAD authentication settings of the cluster. + AzureActiveDirectory *AzureActiveDirectory `json:"azureActiveDirectory,omitempty"` + // Certificate - The certificate to use for securing the cluster. The certificate provided will be used for node to node security within the cluster, SSL certificate for cluster management endpoint and default admin client. + Certificate *CertificateDescription `json:"certificate,omitempty"` + // CertificateCommonNames - Describes a list of server certificates referenced by common name that are used to secure the cluster. + CertificateCommonNames *ServerCertificateCommonNames `json:"certificateCommonNames,omitempty"` + // ClientCertificateCommonNames - The list of client certificates referenced by common name that are allowed to manage the cluster. + ClientCertificateCommonNames *[]ClientCertificateCommonName `json:"clientCertificateCommonNames,omitempty"` + // ClientCertificateThumbprints - The list of client certificates referenced by thumbprint that are allowed to manage the cluster. + ClientCertificateThumbprints *[]ClientCertificateThumbprint `json:"clientCertificateThumbprints,omitempty"` + // ClusterCodeVersion - The Service Fabric runtime version of the cluster. This property can only by set the user when **upgradeMode** is set to 'Manual'. To get list of available Service Fabric versions for new clusters use [ClusterVersion API](./ClusterVersion.md). To get the list of available version for existing clusters use **availableClusterVersions**. + ClusterCodeVersion *string `json:"clusterCodeVersion,omitempty"` + // ClusterEndpoint - The Azure Resource Provider endpoint. A system service in the cluster connects to this endpoint. + ClusterEndpoint *string `json:"clusterEndpoint,omitempty"` + // ClusterID - A service generated unique identifier for the cluster resource. + ClusterID *string `json:"clusterId,omitempty"` + // ClusterState - The current state of the cluster. + // - WaitingForNodes - Indicates that the cluster resource is created and the resource provider is waiting for Service Fabric VM extension to boot up and report to it. + // - Deploying - Indicates that the Service Fabric runtime is being installed on the VMs. Cluster resource will be in this state until the cluster boots up and system services are up. + // - BaselineUpgrade - Indicates that the cluster is upgrading to establishes the cluster version. This upgrade is automatically initiated when the cluster boots up for the first time. + // - UpdatingUserConfiguration - Indicates that the cluster is being upgraded with the user provided configuration. + // - UpdatingUserCertificate - Indicates that the cluster is being upgraded with the user provided certificate. + // - UpdatingInfrastructure - Indicates that the cluster is being upgraded with the latest Service Fabric runtime version. This happens only when the **upgradeMode** is set to 'Automatic'. + // - EnforcingClusterVersion - Indicates that cluster is on a different version than expected and the cluster is being upgraded to the expected version. + // - UpgradeServiceUnreachable - Indicates that the system service in the cluster is no longer polling the Resource Provider. Clusters in this state cannot be managed by the Resource Provider. + // - AutoScale - Indicates that the ReliabilityLevel of the cluster is being adjusted. + // - Ready - Indicates that the cluster is in a stable state. + // . Possible values include: 'WaitingForNodes', 'Deploying', 'BaselineUpgrade', 'UpdatingUserConfiguration', 'UpdatingUserCertificate', 'UpdatingInfrastructure', 'EnforcingClusterVersion', 'UpgradeServiceUnreachable', 'AutoScale', 'Ready' + ClusterState ClusterState `json:"clusterState,omitempty"` + // DiagnosticsStorageAccountConfig - The storage account information for storing Service Fabric diagnostic logs. + DiagnosticsStorageAccountConfig *DiagnosticsStorageAccountConfig `json:"diagnosticsStorageAccountConfig,omitempty"` + // FabricSettings - The list of custom fabric settings to configure the cluster. + FabricSettings *[]SettingsSectionDescription `json:"fabricSettings,omitempty"` + // ManagementEndpoint - The http management endpoint of the cluster. + ManagementEndpoint *string `json:"managementEndpoint,omitempty"` + // NodeTypes - The list of node types in the cluster. + NodeTypes *[]NodeTypeDescription `json:"nodeTypes,omitempty"` + // ProvisioningState - The provisioning state of the cluster resource. Possible values include: 'Updating', 'Succeeded', 'Failed', 'Canceled' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ReliabilityLevel - The reliability level sets the replica set size of system services. Learn about [ReliabilityLevel](https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-cluster-capacity). + // - None - Run the System services with a target replica set count of 1. This should only be used for test clusters. + // - Bronze - Run the System services with a target replica set count of 3. This should only be used for test clusters. + // - Silver - Run the System services with a target replica set count of 5. + // - Gold - Run the System services with a target replica set count of 7. + // - Platinum - Run the System services with a target replica set count of 9. + // . Possible values include: 'ReliabilityLevelNone', 'ReliabilityLevelBronze', 'ReliabilityLevelSilver', 'ReliabilityLevelGold', 'ReliabilityLevelPlatinum' + ReliabilityLevel ReliabilityLevel `json:"reliabilityLevel,omitempty"` + // ReverseProxyCertificate - The server certificate used by reverse proxy. + ReverseProxyCertificate *CertificateDescription `json:"reverseProxyCertificate,omitempty"` + // ReverseProxyCertificateCommonNames - Describes a list of server certificates referenced by common name that are used to secure the cluster. + ReverseProxyCertificateCommonNames *ServerCertificateCommonNames `json:"reverseProxyCertificateCommonNames,omitempty"` + // UpgradeDescription - The policy to use when upgrading the cluster. + UpgradeDescription *ClusterUpgradePolicy `json:"upgradeDescription,omitempty"` + // UpgradeMode - The upgrade mode of the cluster when new Service Fabric runtime version is available. + // - Automatic - The cluster will be automatically upgraded to the latest Service Fabric runtime version as soon as it is available. + // - Manual - The cluster will not be automatically upgraded to the latest Service Fabric runtime version. The cluster is upgraded by setting the **clusterCodeVersion** property in the cluster resource. + // . Possible values include: 'Automatic', 'Manual' + UpgradeMode UpgradeMode `json:"upgradeMode,omitempty"` + // VMImage - The VM image VMSS has been configured with. Generic names such as Windows or Linux can be used. + VMImage *string `json:"vmImage,omitempty"` +} + +// ClusterPropertiesUpdateParameters describes the cluster resource properties that can be updated during PATCH +// operation. +type ClusterPropertiesUpdateParameters struct { + // AddOnFeatures - The list of add-on features to enable in the cluster. + AddOnFeatures *[]string `json:"addOnFeatures,omitempty"` + // Certificate - The certificate to use for securing the cluster. The certificate provided will be used for node to node security within the cluster, SSL certificate for cluster management endpoint and default admin client. + Certificate *CertificateDescription `json:"certificate,omitempty"` + // CertificateCommonNames - Describes a list of server certificates referenced by common name that are used to secure the cluster. + CertificateCommonNames *ServerCertificateCommonNames `json:"certificateCommonNames,omitempty"` + // ClientCertificateCommonNames - The list of client certificates referenced by common name that are allowed to manage the cluster. This will overwrite the existing list. + ClientCertificateCommonNames *[]ClientCertificateCommonName `json:"clientCertificateCommonNames,omitempty"` + // ClientCertificateThumbprints - The list of client certificates referenced by thumbprint that are allowed to manage the cluster. This will overwrite the existing list. + ClientCertificateThumbprints *[]ClientCertificateThumbprint `json:"clientCertificateThumbprints,omitempty"` + // ClusterCodeVersion - The Service Fabric runtime version of the cluster. This property can only by set the user when **upgradeMode** is set to 'Manual'. To get list of available Service Fabric versions for new clusters use [ClusterVersion API](./ClusterVersion.md). To get the list of available version for existing clusters use **availableClusterVersions**. + ClusterCodeVersion *string `json:"clusterCodeVersion,omitempty"` + // FabricSettings - The list of custom fabric settings to configure the cluster. This will overwrite the existing list. + FabricSettings *[]SettingsSectionDescription `json:"fabricSettings,omitempty"` + // NodeTypes - The list of node types in the cluster. This will overwrite the existing list. + NodeTypes *[]NodeTypeDescription `json:"nodeTypes,omitempty"` + // ReliabilityLevel - The reliability level sets the replica set size of system services. Learn about [ReliabilityLevel](https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-cluster-capacity). + // - None - Run the System services with a target replica set count of 1. This should only be used for test clusters. + // - Bronze - Run the System services with a target replica set count of 3. This should only be used for test clusters. + // - Silver - Run the System services with a target replica set count of 5. + // - Gold - Run the System services with a target replica set count of 7. + // - Platinum - Run the System services with a target replica set count of 9. + // . Possible values include: 'ReliabilityLevel1None', 'ReliabilityLevel1Bronze', 'ReliabilityLevel1Silver', 'ReliabilityLevel1Gold', 'ReliabilityLevel1Platinum' + ReliabilityLevel ReliabilityLevel1 `json:"reliabilityLevel,omitempty"` + // ReverseProxyCertificate - The server certificate used by reverse proxy. + ReverseProxyCertificate *CertificateDescription `json:"reverseProxyCertificate,omitempty"` + // UpgradeDescription - The policy to use when upgrading the cluster. + UpgradeDescription *ClusterUpgradePolicy `json:"upgradeDescription,omitempty"` + // UpgradeMode - The upgrade mode of the cluster when new Service Fabric runtime version is available. + // - Automatic - The cluster will be automatically upgraded to the latest Service Fabric runtime version as soon as it is available. + // - Manual - The cluster will not be automatically upgraded to the latest Service Fabric runtime version. The cluster is upgraded by setting the **clusterCodeVersion** property in the cluster resource. + // . Possible values include: 'UpgradeMode1Automatic', 'UpgradeMode1Manual' + UpgradeMode UpgradeMode1 `json:"upgradeMode,omitempty"` +} + +// ClustersCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ClustersCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ClustersCreateFuture) Result(client ClustersClient) (c Cluster, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ClustersCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.CreateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersCreateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ClustersUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ClustersUpdateFuture) Result(client ClustersClient) (c Cluster, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.UpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ClustersUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// ClusterUpdateParameters cluster update request +type ClusterUpdateParameters struct { + // ClusterPropertiesUpdateParameters - Describes the cluster resource properties that can be updated during PATCH operation. + *ClusterPropertiesUpdateParameters `json:"properties,omitempty"` + // Tags - Cluster update parameters + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ClusterUpdateParameters. +func (cup ClusterUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cup.ClusterPropertiesUpdateParameters != nil { + objectMap["properties"] = cup.ClusterPropertiesUpdateParameters + } + if cup.Tags != nil { + objectMap["tags"] = cup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ClusterUpdateParameters struct. +func (cup *ClusterUpdateParameters) 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 clusterPropertiesUpdateParameters ClusterPropertiesUpdateParameters + err = json.Unmarshal(*v, &clusterPropertiesUpdateParameters) + if err != nil { + return err + } + cup.ClusterPropertiesUpdateParameters = &clusterPropertiesUpdateParameters + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + cup.Tags = tags + } + } + } + + return nil +} + +// ClusterUpgradeDeltaHealthPolicy describes the delta health policies for the cluster upgrade. +type ClusterUpgradeDeltaHealthPolicy struct { + // MaxPercentDeltaUnhealthyNodes - The maximum allowed percentage of nodes health degradation allowed during cluster upgrades. + // The delta is measured between the state of the nodes at the beginning of upgrade and the state of the nodes at the time of the health evaluation. + // The check is performed after every upgrade domain upgrade completion to make sure the global state of the cluster is within tolerated limits. + MaxPercentDeltaUnhealthyNodes *int32 `json:"maxPercentDeltaUnhealthyNodes,omitempty"` + // MaxPercentUpgradeDomainDeltaUnhealthyNodes - The maximum allowed percentage of upgrade domain nodes health degradation allowed during cluster upgrades. + // The delta is measured between the state of the upgrade domain nodes at the beginning of upgrade and the state of the upgrade domain nodes at the time of the health evaluation. + // The check is performed after every upgrade domain upgrade completion for all completed upgrade domains to make sure the state of the upgrade domains is within tolerated limits. + MaxPercentUpgradeDomainDeltaUnhealthyNodes *int32 `json:"maxPercentUpgradeDomainDeltaUnhealthyNodes,omitempty"` + // MaxPercentDeltaUnhealthyApplications - The maximum allowed percentage of applications health degradation allowed during cluster upgrades. + // The delta is measured between the state of the applications at the beginning of upgrade and the state of the applications at the time of the health evaluation. + // The check is performed after every upgrade domain upgrade completion to make sure the global state of the cluster is within tolerated limits. System services are not included in this. + MaxPercentDeltaUnhealthyApplications *int32 `json:"maxPercentDeltaUnhealthyApplications,omitempty"` + // ApplicationDeltaHealthPolicies - Defines the application delta health policy map used to evaluate the health of an application or one of its child entities when upgrading the cluster. + ApplicationDeltaHealthPolicies map[string]*ApplicationDeltaHealthPolicy `json:"applicationDeltaHealthPolicies"` +} + +// MarshalJSON is the custom marshaler for ClusterUpgradeDeltaHealthPolicy. +func (cudhp ClusterUpgradeDeltaHealthPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cudhp.MaxPercentDeltaUnhealthyNodes != nil { + objectMap["maxPercentDeltaUnhealthyNodes"] = cudhp.MaxPercentDeltaUnhealthyNodes + } + if cudhp.MaxPercentUpgradeDomainDeltaUnhealthyNodes != nil { + objectMap["maxPercentUpgradeDomainDeltaUnhealthyNodes"] = cudhp.MaxPercentUpgradeDomainDeltaUnhealthyNodes + } + if cudhp.MaxPercentDeltaUnhealthyApplications != nil { + objectMap["maxPercentDeltaUnhealthyApplications"] = cudhp.MaxPercentDeltaUnhealthyApplications + } + if cudhp.ApplicationDeltaHealthPolicies != nil { + objectMap["applicationDeltaHealthPolicies"] = cudhp.ApplicationDeltaHealthPolicies + } + return json.Marshal(objectMap) +} + +// ClusterUpgradePolicy describes the policy used when upgrading the cluster. +type ClusterUpgradePolicy struct { + // ForceRestart - If true, then processes are forcefully restarted during upgrade even when the code version has not changed (the upgrade only changes configuration or data). + ForceRestart *bool `json:"forceRestart,omitempty"` + // UpgradeReplicaSetCheckTimeout - The maximum amount of time to block processing of an upgrade domain and revent loss of availability when there are unexpected issues. When this timeout expires, processing of the upgrade domain will proceed regardless of availability loss issues. The timeout is reset at the start of each upgrade domain. The timeout can be in either hh:mm:ss or in d.hh:mm:ss.ms format. + UpgradeReplicaSetCheckTimeout *string `json:"upgradeReplicaSetCheckTimeout,omitempty"` + // HealthCheckWaitDuration - The length of time to wait after completing an upgrade domain before performing health checks. The duration can be in either hh:mm:ss or in d.hh:mm:ss.ms format. + HealthCheckWaitDuration *string `json:"healthCheckWaitDuration,omitempty"` + // HealthCheckStableDuration - The amount of time that the application or cluster must remain healthy before the upgrade proceeds to the next upgrade domain. The duration can be in either hh:mm:ss or in d.hh:mm:ss.ms format. + HealthCheckStableDuration *string `json:"healthCheckStableDuration,omitempty"` + // HealthCheckRetryTimeout - The amount of time to retry health evaluation when the application or cluster is unhealthy before the upgrade rolls back. The timeout can be in either hh:mm:ss or in d.hh:mm:ss.ms format. + HealthCheckRetryTimeout *string `json:"healthCheckRetryTimeout,omitempty"` + // UpgradeTimeout - The amount of time the overall upgrade has to complete before the upgrade rolls back. The timeout can be in either hh:mm:ss or in d.hh:mm:ss.ms format. + UpgradeTimeout *string `json:"upgradeTimeout,omitempty"` + // UpgradeDomainTimeout - The amount of time each upgrade domain has to complete before the upgrade rolls back. The timeout can be in either hh:mm:ss or in d.hh:mm:ss.ms format. + UpgradeDomainTimeout *string `json:"upgradeDomainTimeout,omitempty"` + // HealthPolicy - The cluster health policy used when upgrading the cluster. + HealthPolicy *ClusterHealthPolicy `json:"healthPolicy,omitempty"` + // DeltaHealthPolicy - The cluster delta health policy used when upgrading the cluster. + DeltaHealthPolicy *ClusterUpgradeDeltaHealthPolicy `json:"deltaHealthPolicy,omitempty"` +} + +// ClusterVersionDetails the detail of the Service Fabric runtime version result +type ClusterVersionDetails struct { + // CodeVersion - The Service Fabric runtime version of the cluster. + CodeVersion *string `json:"codeVersion,omitempty"` + // SupportExpiryUtc - The date of expiry of support of the version. + SupportExpiryUtc *string `json:"supportExpiryUtc,omitempty"` + // Environment - Indicates if this version is for Windows or Linux operating system. Possible values include: 'Windows', 'Linux' + Environment Environment `json:"environment,omitempty"` +} + +// DiagnosticsStorageAccountConfig the storage account information for storing Service Fabric diagnostic logs. +type DiagnosticsStorageAccountConfig struct { + // StorageAccountName - The Azure storage account name. + StorageAccountName *string `json:"storageAccountName,omitempty"` + // ProtectedAccountKeyName - The protected diagnostics storage key name. + ProtectedAccountKeyName *string `json:"protectedAccountKeyName,omitempty"` + // BlobEndpoint - The blob endpoint of the azure storage account. + BlobEndpoint *string `json:"blobEndpoint,omitempty"` + // QueueEndpoint - The queue endpoint of the azure storage account. + QueueEndpoint *string `json:"queueEndpoint,omitempty"` + // TableEndpoint - The table endpoint of the azure storage account. + TableEndpoint *string `json:"tableEndpoint,omitempty"` +} + +// EndpointRangeDescription port range details +type EndpointRangeDescription struct { + // StartPort - Starting port of a range of ports + StartPort *int32 `json:"startPort,omitempty"` + // EndPort - End port of a range of ports + EndPort *int32 `json:"endPort,omitempty"` +} + +// ErrorModel the structure of the error. +type ErrorModel struct { + // Error - The error details. + Error *ErrorModelError `json:"error,omitempty"` +} + +// ErrorModelError the error details. +type ErrorModelError struct { + // Code - The error code. + Code *string `json:"code,omitempty"` + // Message - The error message. + Message *string `json:"message,omitempty"` +} + +// NamedPartitionSchemeDescription describes the named partition scheme of the service. +type NamedPartitionSchemeDescription struct { + // Count - The number of partitions. + Count *int32 `json:"Count,omitempty"` + // Names - Array of size specified by the ‘Count’ parameter, for the names of the partitions. + Names *[]string `json:"Names,omitempty"` + // PartitionScheme - Possible values include: 'PartitionSchemePartitionSchemeDescription', 'PartitionSchemeNamed', 'PartitionSchemeSingleton', 'PartitionSchemeUniformInt64Range' + PartitionScheme PartitionSchemeBasicPartitionSchemeDescription `json:"PartitionScheme,omitempty"` +} + +// MarshalJSON is the custom marshaler for NamedPartitionSchemeDescription. +func (npsd NamedPartitionSchemeDescription) MarshalJSON() ([]byte, error) { + npsd.PartitionScheme = PartitionSchemeNamed + objectMap := make(map[string]interface{}) + if npsd.Count != nil { + objectMap["Count"] = npsd.Count + } + if npsd.Names != nil { + objectMap["Names"] = npsd.Names + } + if npsd.PartitionScheme != "" { + objectMap["PartitionScheme"] = npsd.PartitionScheme + } + return json.Marshal(objectMap) +} + +// AsNamedPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for NamedPartitionSchemeDescription. +func (npsd NamedPartitionSchemeDescription) AsNamedPartitionSchemeDescription() (*NamedPartitionSchemeDescription, bool) { + return &npsd, true +} + +// AsSingletonPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for NamedPartitionSchemeDescription. +func (npsd NamedPartitionSchemeDescription) AsSingletonPartitionSchemeDescription() (*SingletonPartitionSchemeDescription, bool) { + return nil, false +} + +// AsUniformInt64RangePartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for NamedPartitionSchemeDescription. +func (npsd NamedPartitionSchemeDescription) AsUniformInt64RangePartitionSchemeDescription() (*UniformInt64RangePartitionSchemeDescription, bool) { + return nil, false +} + +// AsPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for NamedPartitionSchemeDescription. +func (npsd NamedPartitionSchemeDescription) AsPartitionSchemeDescription() (*PartitionSchemeDescription, bool) { + return nil, false +} + +// AsBasicPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for NamedPartitionSchemeDescription. +func (npsd NamedPartitionSchemeDescription) AsBasicPartitionSchemeDescription() (BasicPartitionSchemeDescription, bool) { + return &npsd, true +} + +// NodeTypeDescription describes a node type in the cluster, each node type represents sub set of nodes in the +// cluster. +type NodeTypeDescription struct { + // Name - The name of the node type. + Name *string `json:"name,omitempty"` + // PlacementProperties - The placement tags applied to nodes in the node type, which can be used to indicate where certain services (workload) should run. + PlacementProperties map[string]*string `json:"placementProperties"` + // Capacities - The capacity tags applied to the nodes in the node type, the cluster resource manager uses these tags to understand how much resource a node has. + Capacities map[string]*string `json:"capacities"` + // ClientConnectionEndpointPort - The TCP cluster management endpoint port. + ClientConnectionEndpointPort *int32 `json:"clientConnectionEndpointPort,omitempty"` + // HTTPGatewayEndpointPort - The HTTP cluster management endpoint port. + HTTPGatewayEndpointPort *int32 `json:"httpGatewayEndpointPort,omitempty"` + // DurabilityLevel - The durability level of the node type. Learn about [DurabilityLevel](https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-cluster-capacity). + // - Bronze - No privileges. This is the default. + // - Silver - The infrastructure jobs can be paused for a duration of 10 minutes per UD. + // - Gold - The infrastructure jobs can be paused for a duration of 2 hours per UD. Gold durability can be enabled only on full node VM skus like D15_V2, G5 etc. + // . Possible values include: 'Bronze', 'Silver', 'Gold' + DurabilityLevel DurabilityLevel `json:"durabilityLevel,omitempty"` + // ApplicationPorts - The range of ports from which cluster assigned port to Service Fabric applications. + ApplicationPorts *EndpointRangeDescription `json:"applicationPorts,omitempty"` + // EphemeralPorts - The range of empheral ports that nodes in this node type should be configured with. + EphemeralPorts *EndpointRangeDescription `json:"ephemeralPorts,omitempty"` + // IsPrimary - The node type on which system services will run. Only one node type should be marked as primary. Primary node type cannot be deleted or changed for existing clusters. + IsPrimary *bool `json:"isPrimary,omitempty"` + // VMInstanceCount - The number of nodes in the node type. This count should match the capacity property in the corresponding VirtualMachineScaleSet resource. + VMInstanceCount *int32 `json:"vmInstanceCount,omitempty"` + // ReverseProxyEndpointPort - The endpoint used by reverse proxy. + ReverseProxyEndpointPort *int32 `json:"reverseProxyEndpointPort,omitempty"` +} + +// MarshalJSON is the custom marshaler for NodeTypeDescription. +func (ntd NodeTypeDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ntd.Name != nil { + objectMap["name"] = ntd.Name + } + if ntd.PlacementProperties != nil { + objectMap["placementProperties"] = ntd.PlacementProperties + } + if ntd.Capacities != nil { + objectMap["capacities"] = ntd.Capacities + } + if ntd.ClientConnectionEndpointPort != nil { + objectMap["clientConnectionEndpointPort"] = ntd.ClientConnectionEndpointPort + } + if ntd.HTTPGatewayEndpointPort != nil { + objectMap["httpGatewayEndpointPort"] = ntd.HTTPGatewayEndpointPort + } + if ntd.DurabilityLevel != "" { + objectMap["durabilityLevel"] = ntd.DurabilityLevel + } + if ntd.ApplicationPorts != nil { + objectMap["applicationPorts"] = ntd.ApplicationPorts + } + if ntd.EphemeralPorts != nil { + objectMap["ephemeralPorts"] = ntd.EphemeralPorts + } + if ntd.IsPrimary != nil { + objectMap["isPrimary"] = ntd.IsPrimary + } + if ntd.VMInstanceCount != nil { + objectMap["vmInstanceCount"] = ntd.VMInstanceCount + } + if ntd.ReverseProxyEndpointPort != nil { + objectMap["reverseProxyEndpointPort"] = ntd.ReverseProxyEndpointPort + } + return json.Marshal(objectMap) +} + +// 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 - 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 +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter 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] +} + +// 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() (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of OperationResult values. +type OperationListResultPage struct { + fn func(OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) Next() error { + next, err := page.fn(page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// 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 +} + +// OperationResult available operation list result +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"` +} + +// BasicPartitionSchemeDescription describes how the service is partitioned. +type BasicPartitionSchemeDescription interface { + AsNamedPartitionSchemeDescription() (*NamedPartitionSchemeDescription, bool) + AsSingletonPartitionSchemeDescription() (*SingletonPartitionSchemeDescription, bool) + AsUniformInt64RangePartitionSchemeDescription() (*UniformInt64RangePartitionSchemeDescription, bool) + AsPartitionSchemeDescription() (*PartitionSchemeDescription, bool) +} + +// PartitionSchemeDescription describes how the service is partitioned. +type PartitionSchemeDescription struct { + // PartitionScheme - Possible values include: 'PartitionSchemePartitionSchemeDescription', 'PartitionSchemeNamed', 'PartitionSchemeSingleton', 'PartitionSchemeUniformInt64Range' + PartitionScheme PartitionSchemeBasicPartitionSchemeDescription `json:"PartitionScheme,omitempty"` +} + +func unmarshalBasicPartitionSchemeDescription(body []byte) (BasicPartitionSchemeDescription, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["PartitionScheme"] { + case string(PartitionSchemeNamed): + var npsd NamedPartitionSchemeDescription + err := json.Unmarshal(body, &npsd) + return npsd, err + case string(PartitionSchemeSingleton): + var spsd SingletonPartitionSchemeDescription + err := json.Unmarshal(body, &spsd) + return spsd, err + case string(PartitionSchemeUniformInt64Range): + var ui6rpsd UniformInt64RangePartitionSchemeDescription + err := json.Unmarshal(body, &ui6rpsd) + return ui6rpsd, err + default: + var psd PartitionSchemeDescription + err := json.Unmarshal(body, &psd) + return psd, err + } +} +func unmarshalBasicPartitionSchemeDescriptionArray(body []byte) ([]BasicPartitionSchemeDescription, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + psdArray := make([]BasicPartitionSchemeDescription, len(rawMessages)) + + for index, rawMessage := range rawMessages { + psd, err := unmarshalBasicPartitionSchemeDescription(*rawMessage) + if err != nil { + return nil, err + } + psdArray[index] = psd + } + return psdArray, nil +} + +// MarshalJSON is the custom marshaler for PartitionSchemeDescription. +func (psd PartitionSchemeDescription) MarshalJSON() ([]byte, error) { + psd.PartitionScheme = PartitionSchemePartitionSchemeDescription + objectMap := make(map[string]interface{}) + if psd.PartitionScheme != "" { + objectMap["PartitionScheme"] = psd.PartitionScheme + } + return json.Marshal(objectMap) +} + +// AsNamedPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for PartitionSchemeDescription. +func (psd PartitionSchemeDescription) AsNamedPartitionSchemeDescription() (*NamedPartitionSchemeDescription, bool) { + return nil, false +} + +// AsSingletonPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for PartitionSchemeDescription. +func (psd PartitionSchemeDescription) AsSingletonPartitionSchemeDescription() (*SingletonPartitionSchemeDescription, bool) { + return nil, false +} + +// AsUniformInt64RangePartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for PartitionSchemeDescription. +func (psd PartitionSchemeDescription) AsUniformInt64RangePartitionSchemeDescription() (*UniformInt64RangePartitionSchemeDescription, bool) { + return nil, false +} + +// AsPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for PartitionSchemeDescription. +func (psd PartitionSchemeDescription) AsPartitionSchemeDescription() (*PartitionSchemeDescription, bool) { + return &psd, true +} + +// AsBasicPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for PartitionSchemeDescription. +func (psd PartitionSchemeDescription) AsBasicPartitionSchemeDescription() (BasicPartitionSchemeDescription, bool) { + return &psd, true +} + +// ProxyResource the resource model definition for proxy-only resource. +type ProxyResource struct { + // ID - Azure resource identifier. + ID *string `json:"id,omitempty"` + // Name - Azure resource name. + Name *string `json:"name,omitempty"` + // Type - Azure resource type. + Type *string `json:"type,omitempty"` + // Location - Azure resource location. + Location *string `json:"location,omitempty"` +} + +// Resource the resource model definition. +type Resource struct { + // ID - Azure resource identifier. + ID *string `json:"id,omitempty"` + // Name - Azure resource name. + Name *string `json:"name,omitempty"` + // Type - Azure resource type. + Type *string `json:"type,omitempty"` + // Location - Azure resource location. + Location *string `json:"location,omitempty"` + // Tags - Azure resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.ID != nil { + objectMap["id"] = r.ID + } + if r.Name != nil { + objectMap["name"] = r.Name + } + if r.Type != nil { + objectMap["type"] = r.Type + } + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// RollingUpgradeMonitoringPolicy the policy used for monitoring the application upgrade +type RollingUpgradeMonitoringPolicy struct { + // HealthCheckWaitDuration - The amount of time to wait after completing an upgrade domain before applying health policies. It is first interpreted as a string representing an ISO 8601 duration. If that fails, then it is interpreted as a number representing the total number of milliseconds. + HealthCheckWaitDuration *string `json:"healthCheckWaitDuration,omitempty"` + // HealthCheckStableDuration - The amount of time that the application or cluster must remain healthy before the upgrade proceeds to the next upgrade domain. It is first interpreted as a string representing an ISO 8601 duration. If that fails, then it is interpreted as a number representing the total number of milliseconds. + HealthCheckStableDuration *string `json:"healthCheckStableDuration,omitempty"` + // HealthCheckRetryTimeout - The amount of time to retry health evaluation when the application or cluster is unhealthy before FailureAction is executed. It is first interpreted as a string representing an ISO 8601 duration. If that fails, then it is interpreted as a number representing the total number of milliseconds. + HealthCheckRetryTimeout *string `json:"healthCheckRetryTimeout,omitempty"` + // UpgradeTimeout - The amount of time the overall upgrade has to complete before FailureAction is executed. It is first interpreted as a string representing an ISO 8601 duration. If that fails, then it is interpreted as a number representing the total number of milliseconds. + UpgradeTimeout *string `json:"upgradeTimeout,omitempty"` + // UpgradeDomainTimeout - The amount of time each upgrade domain has to complete before FailureAction is executed. It is first interpreted as a string representing an ISO 8601 duration. If that fails, then it is interpreted as a number representing the total number of milliseconds. + UpgradeDomainTimeout *string `json:"upgradeDomainTimeout,omitempty"` +} + +// ServerCertificateCommonName describes the server certificate details using common name. +type ServerCertificateCommonName struct { + // CertificateCommonName - The common name of the server certificate. + CertificateCommonName *string `json:"certificateCommonName,omitempty"` + // CertificateIssuerThumbprint - The issuer thumbprint of the server certificate. + CertificateIssuerThumbprint *string `json:"certificateIssuerThumbprint,omitempty"` +} + +// ServerCertificateCommonNames describes a list of server certificates referenced by common name that are used to +// secure the cluster. +type ServerCertificateCommonNames struct { + // CommonNames - The list of server certificates referenced by common name that are used to secure the cluster. + CommonNames *[]ServerCertificateCommonName `json:"commonNames,omitempty"` + // X509StoreName - The local certificate store location. Possible values include: 'X509StoreName1AddressBook', 'X509StoreName1AuthRoot', 'X509StoreName1CertificateAuthority', 'X509StoreName1Disallowed', 'X509StoreName1My', 'X509StoreName1Root', 'X509StoreName1TrustedPeople', 'X509StoreName1TrustedPublisher' + X509StoreName X509StoreName1 `json:"x509StoreName,omitempty"` +} + +// ServiceCorrelationDescription creates a particular correlation between services. +type ServiceCorrelationDescription struct { + // Scheme - The ServiceCorrelationScheme which describes the relationship between this service and the service specified via ServiceName. Possible values include: 'ServiceCorrelationSchemeInvalid', 'ServiceCorrelationSchemeAffinity', 'ServiceCorrelationSchemeAlignedAffinity', 'ServiceCorrelationSchemeNonAlignedAffinity' + Scheme ServiceCorrelationScheme `json:"Scheme,omitempty"` + // ServiceName - The name of the service that the correlation relationship is established with. + ServiceName *string `json:"ServiceName,omitempty"` +} + +// ServiceLoadMetricDescription specifies a metric to load balance a service during runtime. +type ServiceLoadMetricDescription struct { + // Name - The name of the metric. If the service chooses to report load during runtime, the load metric name should match the name that is specified in Name exactly. Note that metric names are case sensitive. + Name *string `json:"Name,omitempty"` + // Weight - The service load metric relative weight, compared to other metrics configured for this service, as a number. Possible values include: 'ServiceLoadMetricWeightZero', 'ServiceLoadMetricWeightLow', 'ServiceLoadMetricWeightMedium', 'ServiceLoadMetricWeightHigh' + Weight ServiceLoadMetricWeight `json:"Weight,omitempty"` + // PrimaryDefaultLoad - Used only for Stateful services. The default amount of load, as a number, that this service creates for this metric when it is a Primary replica. + PrimaryDefaultLoad *int32 `json:"PrimaryDefaultLoad,omitempty"` + // SecondaryDefaultLoad - Used only for Stateful services. The default amount of load, as a number, that this service creates for this metric when it is a Secondary replica. + SecondaryDefaultLoad *int32 `json:"SecondaryDefaultLoad,omitempty"` + // DefaultLoad - Used only for Stateless services. The default amount of load, as a number, that this service creates for this metric. + DefaultLoad *int32 `json:"DefaultLoad,omitempty"` +} + +// BasicServicePlacementPolicyDescription describes the policy to be used for placement of a Service Fabric service. +type BasicServicePlacementPolicyDescription interface { + AsServicePlacementPolicyDescription() (*ServicePlacementPolicyDescription, bool) +} + +// ServicePlacementPolicyDescription describes the policy to be used for placement of a Service Fabric service. +type ServicePlacementPolicyDescription struct { + // Type - Possible values include: 'TypeServicePlacementPolicyDescription' + Type Type `json:"Type,omitempty"` +} + +func unmarshalBasicServicePlacementPolicyDescription(body []byte) (BasicServicePlacementPolicyDescription, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["Type"] { + default: + var sppd ServicePlacementPolicyDescription + err := json.Unmarshal(body, &sppd) + return sppd, err + } +} +func unmarshalBasicServicePlacementPolicyDescriptionArray(body []byte) ([]BasicServicePlacementPolicyDescription, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + sppdArray := make([]BasicServicePlacementPolicyDescription, len(rawMessages)) + + for index, rawMessage := range rawMessages { + sppd, err := unmarshalBasicServicePlacementPolicyDescription(*rawMessage) + if err != nil { + return nil, err + } + sppdArray[index] = sppd + } + return sppdArray, nil +} + +// MarshalJSON is the custom marshaler for ServicePlacementPolicyDescription. +func (sppd ServicePlacementPolicyDescription) MarshalJSON() ([]byte, error) { + sppd.Type = TypeServicePlacementPolicyDescription + objectMap := make(map[string]interface{}) + if sppd.Type != "" { + objectMap["Type"] = sppd.Type + } + return json.Marshal(objectMap) +} + +// AsServicePlacementPolicyDescription is the BasicServicePlacementPolicyDescription implementation for ServicePlacementPolicyDescription. +func (sppd ServicePlacementPolicyDescription) AsServicePlacementPolicyDescription() (*ServicePlacementPolicyDescription, bool) { + return &sppd, true +} + +// AsBasicServicePlacementPolicyDescription is the BasicServicePlacementPolicyDescription implementation for ServicePlacementPolicyDescription. +func (sppd ServicePlacementPolicyDescription) AsBasicServicePlacementPolicyDescription() (BasicServicePlacementPolicyDescription, bool) { + return &sppd, true +} + +// ServiceResource the service resource. +type ServiceResource struct { + autorest.Response `json:"-"` + // BasicServiceResourceProperties - The service resource properties. + BasicServiceResourceProperties `json:"properties,omitempty"` + // ID - Azure resource identifier. + ID *string `json:"id,omitempty"` + // Name - Azure resource name. + Name *string `json:"name,omitempty"` + // Type - Azure resource type. + Type *string `json:"type,omitempty"` + // Location - Azure resource location. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceResource. +func (sr ServiceResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["properties"] = sr.BasicServiceResourceProperties + if sr.ID != nil { + objectMap["id"] = sr.ID + } + if sr.Name != nil { + objectMap["name"] = sr.Name + } + if sr.Type != nil { + objectMap["type"] = sr.Type + } + if sr.Location != nil { + objectMap["location"] = sr.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceResource struct. +func (sr *ServiceResource) 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 { + basicServiceResourceProperties, err := unmarshalBasicServiceResourceProperties(*v) + if err != nil { + return err + } + sr.BasicServiceResourceProperties = basicServiceResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sr.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sr.Location = &location + } + } + } + + return nil +} + +// ServiceResourceList the list of service resources. +type ServiceResourceList struct { + autorest.Response `json:"-"` + Value *[]ServiceResource `json:"value,omitempty"` +} + +// BasicServiceResourceProperties the service resource properties. +type BasicServiceResourceProperties interface { + AsStatefulServiceProperties() (*StatefulServiceProperties, bool) + AsStatelessServiceProperties() (*StatelessServiceProperties, bool) + AsServiceResourceProperties() (*ServiceResourceProperties, bool) +} + +// ServiceResourceProperties the service resource properties. +type ServiceResourceProperties struct { + // ProvisioningState - The current deployment or provisioning state, which only appears in the response + ProvisioningState *string `json:"provisioningState,omitempty"` + // ServiceTypeName - The name of the service type + ServiceTypeName *string `json:"serviceTypeName,omitempty"` + // PartitionDescription - Describes how the service is partitioned. + PartitionDescription BasicPartitionSchemeDescription `json:"partitionDescription,omitempty"` + // ServiceKind - Possible values include: 'ServiceKindServiceResourceProperties', 'ServiceKindStateful1', 'ServiceKindStateless1' + ServiceKind ServiceKindBasicServiceResourceProperties `json:"serviceKind,omitempty"` + // PlacementConstraints - The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular nodes based on the service requirements. For example, to place a service on nodes where NodeType is blue specify the following: "NodeColor == blue)". + PlacementConstraints *string `json:"placementConstraints,omitempty"` + // CorrelationScheme - A list that describes the correlation of the service with other services. + CorrelationScheme *[]ServiceCorrelationDescription `json:"correlationScheme,omitempty"` + // ServiceLoadMetrics - The service load metrics is given as an array of ServiceLoadMetricDescription objects. + ServiceLoadMetrics *[]ServiceLoadMetricDescription `json:"serviceLoadMetrics,omitempty"` + // ServicePlacementPolicies - A list that describes the correlation of the service with other services. + ServicePlacementPolicies *[]BasicServicePlacementPolicyDescription `json:"servicePlacementPolicies,omitempty"` + // DefaultMoveCost - Specifies the move cost for the service. Possible values include: 'Zero', 'Low', 'Medium', 'High' + DefaultMoveCost MoveCost `json:"defaultMoveCost,omitempty"` +} + +func unmarshalBasicServiceResourceProperties(body []byte) (BasicServiceResourceProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["serviceKind"] { + case string(ServiceKindStateful1): + var ssp StatefulServiceProperties + err := json.Unmarshal(body, &ssp) + return ssp, err + case string(ServiceKindStateless1): + var ssp StatelessServiceProperties + err := json.Unmarshal(body, &ssp) + return ssp, err + default: + var srp ServiceResourceProperties + err := json.Unmarshal(body, &srp) + return srp, err + } +} +func unmarshalBasicServiceResourcePropertiesArray(body []byte) ([]BasicServiceResourceProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + srpArray := make([]BasicServiceResourceProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + srp, err := unmarshalBasicServiceResourceProperties(*rawMessage) + if err != nil { + return nil, err + } + srpArray[index] = srp + } + return srpArray, nil +} + +// MarshalJSON is the custom marshaler for ServiceResourceProperties. +func (srp ServiceResourceProperties) MarshalJSON() ([]byte, error) { + srp.ServiceKind = ServiceKindServiceResourceProperties + objectMap := make(map[string]interface{}) + if srp.ProvisioningState != nil { + objectMap["provisioningState"] = srp.ProvisioningState + } + if srp.ServiceTypeName != nil { + objectMap["serviceTypeName"] = srp.ServiceTypeName + } + objectMap["partitionDescription"] = srp.PartitionDescription + if srp.ServiceKind != "" { + objectMap["serviceKind"] = srp.ServiceKind + } + if srp.PlacementConstraints != nil { + objectMap["placementConstraints"] = srp.PlacementConstraints + } + if srp.CorrelationScheme != nil { + objectMap["correlationScheme"] = srp.CorrelationScheme + } + if srp.ServiceLoadMetrics != nil { + objectMap["serviceLoadMetrics"] = srp.ServiceLoadMetrics + } + if srp.ServicePlacementPolicies != nil { + objectMap["servicePlacementPolicies"] = srp.ServicePlacementPolicies + } + if srp.DefaultMoveCost != "" { + objectMap["defaultMoveCost"] = srp.DefaultMoveCost + } + return json.Marshal(objectMap) +} + +// AsStatefulServiceProperties is the BasicServiceResourceProperties implementation for ServiceResourceProperties. +func (srp ServiceResourceProperties) AsStatefulServiceProperties() (*StatefulServiceProperties, bool) { + return nil, false +} + +// AsStatelessServiceProperties is the BasicServiceResourceProperties implementation for ServiceResourceProperties. +func (srp ServiceResourceProperties) AsStatelessServiceProperties() (*StatelessServiceProperties, bool) { + return nil, false +} + +// AsServiceResourceProperties is the BasicServiceResourceProperties implementation for ServiceResourceProperties. +func (srp ServiceResourceProperties) AsServiceResourceProperties() (*ServiceResourceProperties, bool) { + return &srp, true +} + +// AsBasicServiceResourceProperties is the BasicServiceResourceProperties implementation for ServiceResourceProperties. +func (srp ServiceResourceProperties) AsBasicServiceResourceProperties() (BasicServiceResourceProperties, bool) { + return &srp, true +} + +// UnmarshalJSON is the custom unmarshaler for ServiceResourceProperties struct. +func (srp *ServiceResourceProperties) 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 "provisioningState": + if v != nil { + var provisioningState string + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + srp.ProvisioningState = &provisioningState + } + case "serviceTypeName": + if v != nil { + var serviceTypeName string + err = json.Unmarshal(*v, &serviceTypeName) + if err != nil { + return err + } + srp.ServiceTypeName = &serviceTypeName + } + case "partitionDescription": + if v != nil { + partitionDescription, err := unmarshalBasicPartitionSchemeDescription(*v) + if err != nil { + return err + } + srp.PartitionDescription = partitionDescription + } + case "serviceKind": + if v != nil { + var serviceKind ServiceKindBasicServiceResourceProperties + err = json.Unmarshal(*v, &serviceKind) + if err != nil { + return err + } + srp.ServiceKind = serviceKind + } + case "placementConstraints": + if v != nil { + var placementConstraints string + err = json.Unmarshal(*v, &placementConstraints) + if err != nil { + return err + } + srp.PlacementConstraints = &placementConstraints + } + case "correlationScheme": + if v != nil { + var correlationScheme []ServiceCorrelationDescription + err = json.Unmarshal(*v, &correlationScheme) + if err != nil { + return err + } + srp.CorrelationScheme = &correlationScheme + } + case "serviceLoadMetrics": + if v != nil { + var serviceLoadMetrics []ServiceLoadMetricDescription + err = json.Unmarshal(*v, &serviceLoadMetrics) + if err != nil { + return err + } + srp.ServiceLoadMetrics = &serviceLoadMetrics + } + case "servicePlacementPolicies": + if v != nil { + servicePlacementPolicies, err := unmarshalBasicServicePlacementPolicyDescriptionArray(*v) + if err != nil { + return err + } + srp.ServicePlacementPolicies = &servicePlacementPolicies + } + case "defaultMoveCost": + if v != nil { + var defaultMoveCost MoveCost + err = json.Unmarshal(*v, &defaultMoveCost) + if err != nil { + return err + } + srp.DefaultMoveCost = defaultMoveCost + } + } + } + + return nil +} + +// ServiceResourcePropertiesBase the common service resource properties. +type ServiceResourcePropertiesBase struct { + // PlacementConstraints - The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular nodes based on the service requirements. For example, to place a service on nodes where NodeType is blue specify the following: "NodeColor == blue)". + PlacementConstraints *string `json:"placementConstraints,omitempty"` + // CorrelationScheme - A list that describes the correlation of the service with other services. + CorrelationScheme *[]ServiceCorrelationDescription `json:"correlationScheme,omitempty"` + // ServiceLoadMetrics - The service load metrics is given as an array of ServiceLoadMetricDescription objects. + ServiceLoadMetrics *[]ServiceLoadMetricDescription `json:"serviceLoadMetrics,omitempty"` + // ServicePlacementPolicies - A list that describes the correlation of the service with other services. + ServicePlacementPolicies *[]BasicServicePlacementPolicyDescription `json:"servicePlacementPolicies,omitempty"` + // DefaultMoveCost - Specifies the move cost for the service. Possible values include: 'Zero', 'Low', 'Medium', 'High' + DefaultMoveCost MoveCost `json:"defaultMoveCost,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for ServiceResourcePropertiesBase struct. +func (srpb *ServiceResourcePropertiesBase) 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 "placementConstraints": + if v != nil { + var placementConstraints string + err = json.Unmarshal(*v, &placementConstraints) + if err != nil { + return err + } + srpb.PlacementConstraints = &placementConstraints + } + case "correlationScheme": + if v != nil { + var correlationScheme []ServiceCorrelationDescription + err = json.Unmarshal(*v, &correlationScheme) + if err != nil { + return err + } + srpb.CorrelationScheme = &correlationScheme + } + case "serviceLoadMetrics": + if v != nil { + var serviceLoadMetrics []ServiceLoadMetricDescription + err = json.Unmarshal(*v, &serviceLoadMetrics) + if err != nil { + return err + } + srpb.ServiceLoadMetrics = &serviceLoadMetrics + } + case "servicePlacementPolicies": + if v != nil { + servicePlacementPolicies, err := unmarshalBasicServicePlacementPolicyDescriptionArray(*v) + if err != nil { + return err + } + srpb.ServicePlacementPolicies = &servicePlacementPolicies + } + case "defaultMoveCost": + if v != nil { + var defaultMoveCost MoveCost + err = json.Unmarshal(*v, &defaultMoveCost) + if err != nil { + return err + } + srpb.DefaultMoveCost = defaultMoveCost + } + } + } + + return nil +} + +// ServiceResourceUpdate the service resource for patch operations. +type ServiceResourceUpdate struct { + autorest.Response `json:"-"` + // BasicServiceResourceUpdateProperties - The service resource properties for patch operations. + BasicServiceResourceUpdateProperties `json:"properties,omitempty"` + // ID - Azure resource identifier. + ID *string `json:"id,omitempty"` + // Name - Azure resource name. + Name *string `json:"name,omitempty"` + // Type - Azure resource type. + Type *string `json:"type,omitempty"` + // Location - Azure resource location. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceResourceUpdate. +func (sru ServiceResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["properties"] = sru.BasicServiceResourceUpdateProperties + if sru.ID != nil { + objectMap["id"] = sru.ID + } + if sru.Name != nil { + objectMap["name"] = sru.Name + } + if sru.Type != nil { + objectMap["type"] = sru.Type + } + if sru.Location != nil { + objectMap["location"] = sru.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServiceResourceUpdate struct. +func (sru *ServiceResourceUpdate) 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 { + basicServiceResourceUpdateProperties, err := unmarshalBasicServiceResourceUpdateProperties(*v) + if err != nil { + return err + } + sru.BasicServiceResourceUpdateProperties = basicServiceResourceUpdateProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sru.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sru.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sru.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sru.Location = &location + } + } + } + + return nil +} + +// BasicServiceResourceUpdateProperties the service resource properties for patch operations. +type BasicServiceResourceUpdateProperties interface { + AsStatefulServiceUpdateProperties() (*StatefulServiceUpdateProperties, bool) + AsStatelessServiceUpdateProperties() (*StatelessServiceUpdateProperties, bool) + AsServiceResourceUpdateProperties() (*ServiceResourceUpdateProperties, bool) +} + +// ServiceResourceUpdateProperties the service resource properties for patch operations. +type ServiceResourceUpdateProperties struct { + // ServiceKind - Possible values include: 'ServiceKindBasicServiceResourceUpdatePropertiesServiceKindServiceResourceUpdateProperties', 'ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateful', 'ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateless' + ServiceKind ServiceKindBasicServiceResourceUpdateProperties `json:"serviceKind,omitempty"` + // PlacementConstraints - The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular nodes based on the service requirements. For example, to place a service on nodes where NodeType is blue specify the following: "NodeColor == blue)". + PlacementConstraints *string `json:"placementConstraints,omitempty"` + // CorrelationScheme - A list that describes the correlation of the service with other services. + CorrelationScheme *[]ServiceCorrelationDescription `json:"correlationScheme,omitempty"` + // ServiceLoadMetrics - The service load metrics is given as an array of ServiceLoadMetricDescription objects. + ServiceLoadMetrics *[]ServiceLoadMetricDescription `json:"serviceLoadMetrics,omitempty"` + // ServicePlacementPolicies - A list that describes the correlation of the service with other services. + ServicePlacementPolicies *[]BasicServicePlacementPolicyDescription `json:"servicePlacementPolicies,omitempty"` + // DefaultMoveCost - Specifies the move cost for the service. Possible values include: 'Zero', 'Low', 'Medium', 'High' + DefaultMoveCost MoveCost `json:"defaultMoveCost,omitempty"` +} + +func unmarshalBasicServiceResourceUpdateProperties(body []byte) (BasicServiceResourceUpdateProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["serviceKind"] { + case string(ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateful): + var ssup StatefulServiceUpdateProperties + err := json.Unmarshal(body, &ssup) + return ssup, err + case string(ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateless): + var ssup StatelessServiceUpdateProperties + err := json.Unmarshal(body, &ssup) + return ssup, err + default: + var srup ServiceResourceUpdateProperties + err := json.Unmarshal(body, &srup) + return srup, err + } +} +func unmarshalBasicServiceResourceUpdatePropertiesArray(body []byte) ([]BasicServiceResourceUpdateProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + srupArray := make([]BasicServiceResourceUpdateProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + srup, err := unmarshalBasicServiceResourceUpdateProperties(*rawMessage) + if err != nil { + return nil, err + } + srupArray[index] = srup + } + return srupArray, nil +} + +// MarshalJSON is the custom marshaler for ServiceResourceUpdateProperties. +func (srup ServiceResourceUpdateProperties) MarshalJSON() ([]byte, error) { + srup.ServiceKind = ServiceKindBasicServiceResourceUpdatePropertiesServiceKindServiceResourceUpdateProperties + objectMap := make(map[string]interface{}) + if srup.ServiceKind != "" { + objectMap["serviceKind"] = srup.ServiceKind + } + if srup.PlacementConstraints != nil { + objectMap["placementConstraints"] = srup.PlacementConstraints + } + if srup.CorrelationScheme != nil { + objectMap["correlationScheme"] = srup.CorrelationScheme + } + if srup.ServiceLoadMetrics != nil { + objectMap["serviceLoadMetrics"] = srup.ServiceLoadMetrics + } + if srup.ServicePlacementPolicies != nil { + objectMap["servicePlacementPolicies"] = srup.ServicePlacementPolicies + } + if srup.DefaultMoveCost != "" { + objectMap["defaultMoveCost"] = srup.DefaultMoveCost + } + return json.Marshal(objectMap) +} + +// AsStatefulServiceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for ServiceResourceUpdateProperties. +func (srup ServiceResourceUpdateProperties) AsStatefulServiceUpdateProperties() (*StatefulServiceUpdateProperties, bool) { + return nil, false +} + +// AsStatelessServiceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for ServiceResourceUpdateProperties. +func (srup ServiceResourceUpdateProperties) AsStatelessServiceUpdateProperties() (*StatelessServiceUpdateProperties, bool) { + return nil, false +} + +// AsServiceResourceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for ServiceResourceUpdateProperties. +func (srup ServiceResourceUpdateProperties) AsServiceResourceUpdateProperties() (*ServiceResourceUpdateProperties, bool) { + return &srup, true +} + +// AsBasicServiceResourceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for ServiceResourceUpdateProperties. +func (srup ServiceResourceUpdateProperties) AsBasicServiceResourceUpdateProperties() (BasicServiceResourceUpdateProperties, bool) { + return &srup, true +} + +// UnmarshalJSON is the custom unmarshaler for ServiceResourceUpdateProperties struct. +func (srup *ServiceResourceUpdateProperties) 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 "serviceKind": + if v != nil { + var serviceKind ServiceKindBasicServiceResourceUpdateProperties + err = json.Unmarshal(*v, &serviceKind) + if err != nil { + return err + } + srup.ServiceKind = serviceKind + } + case "placementConstraints": + if v != nil { + var placementConstraints string + err = json.Unmarshal(*v, &placementConstraints) + if err != nil { + return err + } + srup.PlacementConstraints = &placementConstraints + } + case "correlationScheme": + if v != nil { + var correlationScheme []ServiceCorrelationDescription + err = json.Unmarshal(*v, &correlationScheme) + if err != nil { + return err + } + srup.CorrelationScheme = &correlationScheme + } + case "serviceLoadMetrics": + if v != nil { + var serviceLoadMetrics []ServiceLoadMetricDescription + err = json.Unmarshal(*v, &serviceLoadMetrics) + if err != nil { + return err + } + srup.ServiceLoadMetrics = &serviceLoadMetrics + } + case "servicePlacementPolicies": + if v != nil { + servicePlacementPolicies, err := unmarshalBasicServicePlacementPolicyDescriptionArray(*v) + if err != nil { + return err + } + srup.ServicePlacementPolicies = &servicePlacementPolicies + } + case "defaultMoveCost": + if v != nil { + var defaultMoveCost MoveCost + err = json.Unmarshal(*v, &defaultMoveCost) + if err != nil { + return err + } + srup.DefaultMoveCost = defaultMoveCost + } + } + } + + return nil +} + +// ServicesCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServicesCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServicesCreateFuture) Result(client ServicesClient) (sr ServiceResource, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ServicesCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sr.Response.Response, err = future.GetResult(sender); err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { + sr, err = client.CreateResponder(sr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesCreateFuture", "Result", sr.Response.Response, "Failure responding to request") + } + } + return +} + +// ServicesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServicesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServicesDeleteFuture) Result(client ServicesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ServicesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServicesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ServicesUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ServicesUpdateFuture) Result(client ServicesClient) (sru ServiceResourceUpdate, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("servicefabric.ServicesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sru.Response.Response, err = future.GetResult(sender); err == nil && sru.Response.Response.StatusCode != http.StatusNoContent { + sru, err = client.UpdateResponder(sru.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesUpdateFuture", "Result", sru.Response.Response, "Failure responding to request") + } + } + return +} + +// ServiceTypeDeltaHealthPolicy represents the delta health policy used to evaluate the health of services +// belonging to a service type when upgrading the cluster. +type ServiceTypeDeltaHealthPolicy struct { + // MaxPercentDeltaUnhealthyServices - The maximum allowed percentage of services health degradation allowed during cluster upgrades. + // The delta is measured between the state of the services at the beginning of upgrade and the state of the services at the time of the health evaluation. + // The check is performed after every upgrade domain upgrade completion to make sure the global state of the cluster is within tolerated limits. + MaxPercentDeltaUnhealthyServices *int32 `json:"maxPercentDeltaUnhealthyServices,omitempty"` +} + +// ServiceTypeHealthPolicy represents the health policy used to evaluate the health of services belonging to a +// service type. +type ServiceTypeHealthPolicy struct { + // MaxPercentUnhealthyServices - The maximum percentage of services allowed to be unhealthy before your application is considered in error. + MaxPercentUnhealthyServices *int32 `json:"maxPercentUnhealthyServices,omitempty"` +} + +// SettingsParameterDescription describes a parameter in fabric settings of the cluster. +type SettingsParameterDescription struct { + // Name - The parameter name of fabric setting. + Name *string `json:"name,omitempty"` + // Value - The parameter value of fabric setting. + Value *string `json:"value,omitempty"` +} + +// SettingsSectionDescription describes a section in the fabric settings of the cluster. +type SettingsSectionDescription struct { + // Name - The section name of the fabric settings. + Name *string `json:"name,omitempty"` + // Parameters - The collection of parameters in the section. + Parameters *[]SettingsParameterDescription `json:"parameters,omitempty"` +} + +// SingletonPartitionSchemeDescription describes the partition scheme of a singleton-partitioned, or +// non-partitioned service. +type SingletonPartitionSchemeDescription struct { + // PartitionScheme - Possible values include: 'PartitionSchemePartitionSchemeDescription', 'PartitionSchemeNamed', 'PartitionSchemeSingleton', 'PartitionSchemeUniformInt64Range' + PartitionScheme PartitionSchemeBasicPartitionSchemeDescription `json:"PartitionScheme,omitempty"` +} + +// MarshalJSON is the custom marshaler for SingletonPartitionSchemeDescription. +func (spsd SingletonPartitionSchemeDescription) MarshalJSON() ([]byte, error) { + spsd.PartitionScheme = PartitionSchemeSingleton + objectMap := make(map[string]interface{}) + if spsd.PartitionScheme != "" { + objectMap["PartitionScheme"] = spsd.PartitionScheme + } + return json.Marshal(objectMap) +} + +// AsNamedPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for SingletonPartitionSchemeDescription. +func (spsd SingletonPartitionSchemeDescription) AsNamedPartitionSchemeDescription() (*NamedPartitionSchemeDescription, bool) { + return nil, false +} + +// AsSingletonPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for SingletonPartitionSchemeDescription. +func (spsd SingletonPartitionSchemeDescription) AsSingletonPartitionSchemeDescription() (*SingletonPartitionSchemeDescription, bool) { + return &spsd, true +} + +// AsUniformInt64RangePartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for SingletonPartitionSchemeDescription. +func (spsd SingletonPartitionSchemeDescription) AsUniformInt64RangePartitionSchemeDescription() (*UniformInt64RangePartitionSchemeDescription, bool) { + return nil, false +} + +// AsPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for SingletonPartitionSchemeDescription. +func (spsd SingletonPartitionSchemeDescription) AsPartitionSchemeDescription() (*PartitionSchemeDescription, bool) { + return nil, false +} + +// AsBasicPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for SingletonPartitionSchemeDescription. +func (spsd SingletonPartitionSchemeDescription) AsBasicPartitionSchemeDescription() (BasicPartitionSchemeDescription, bool) { + return &spsd, true +} + +// StatefulServiceProperties the properties of a stateful service resource. +type StatefulServiceProperties struct { + // HasPersistedState - A flag indicating whether this is a persistent service which stores states on the local disk. If it is then the value of this property is true, if not it is false. + HasPersistedState *bool `json:"hasPersistedState,omitempty"` + // TargetReplicaSetSize - The target replica set size as a number. + TargetReplicaSetSize *int32 `json:"targetReplicaSetSize,omitempty"` + // MinReplicaSetSize - The minimum replica set size as a number. + MinReplicaSetSize *int32 `json:"minReplicaSetSize,omitempty"` + // ReplicaRestartWaitDuration - The duration between when a replica goes down and when a new replica is created, represented in ISO 8601 format (hh:mm:ss.s). + ReplicaRestartWaitDuration *date.Time `json:"replicaRestartWaitDuration,omitempty"` + // QuorumLossWaitDuration - The maximum duration for which a partition is allowed to be in a state of quorum loss, represented in ISO 8601 format (hh:mm:ss.s). + QuorumLossWaitDuration *date.Time `json:"quorumLossWaitDuration,omitempty"` + // StandByReplicaKeepDuration - The definition on how long StandBy replicas should be maintained before being removed, represented in ISO 8601 format (hh:mm:ss.s). + StandByReplicaKeepDuration *date.Time `json:"standByReplicaKeepDuration,omitempty"` + // ProvisioningState - The current deployment or provisioning state, which only appears in the response + ProvisioningState *string `json:"provisioningState,omitempty"` + // ServiceTypeName - The name of the service type + ServiceTypeName *string `json:"serviceTypeName,omitempty"` + // PartitionDescription - Describes how the service is partitioned. + PartitionDescription BasicPartitionSchemeDescription `json:"partitionDescription,omitempty"` + // ServiceKind - Possible values include: 'ServiceKindServiceResourceProperties', 'ServiceKindStateful1', 'ServiceKindStateless1' + ServiceKind ServiceKindBasicServiceResourceProperties `json:"serviceKind,omitempty"` + // PlacementConstraints - The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular nodes based on the service requirements. For example, to place a service on nodes where NodeType is blue specify the following: "NodeColor == blue)". + PlacementConstraints *string `json:"placementConstraints,omitempty"` + // CorrelationScheme - A list that describes the correlation of the service with other services. + CorrelationScheme *[]ServiceCorrelationDescription `json:"correlationScheme,omitempty"` + // ServiceLoadMetrics - The service load metrics is given as an array of ServiceLoadMetricDescription objects. + ServiceLoadMetrics *[]ServiceLoadMetricDescription `json:"serviceLoadMetrics,omitempty"` + // ServicePlacementPolicies - A list that describes the correlation of the service with other services. + ServicePlacementPolicies *[]BasicServicePlacementPolicyDescription `json:"servicePlacementPolicies,omitempty"` + // DefaultMoveCost - Specifies the move cost for the service. Possible values include: 'Zero', 'Low', 'Medium', 'High' + DefaultMoveCost MoveCost `json:"defaultMoveCost,omitempty"` +} + +// MarshalJSON is the custom marshaler for StatefulServiceProperties. +func (ssp StatefulServiceProperties) MarshalJSON() ([]byte, error) { + ssp.ServiceKind = ServiceKindStateful1 + objectMap := make(map[string]interface{}) + if ssp.HasPersistedState != nil { + objectMap["hasPersistedState"] = ssp.HasPersistedState + } + if ssp.TargetReplicaSetSize != nil { + objectMap["targetReplicaSetSize"] = ssp.TargetReplicaSetSize + } + if ssp.MinReplicaSetSize != nil { + objectMap["minReplicaSetSize"] = ssp.MinReplicaSetSize + } + if ssp.ReplicaRestartWaitDuration != nil { + objectMap["replicaRestartWaitDuration"] = ssp.ReplicaRestartWaitDuration + } + if ssp.QuorumLossWaitDuration != nil { + objectMap["quorumLossWaitDuration"] = ssp.QuorumLossWaitDuration + } + if ssp.StandByReplicaKeepDuration != nil { + objectMap["standByReplicaKeepDuration"] = ssp.StandByReplicaKeepDuration + } + if ssp.ProvisioningState != nil { + objectMap["provisioningState"] = ssp.ProvisioningState + } + if ssp.ServiceTypeName != nil { + objectMap["serviceTypeName"] = ssp.ServiceTypeName + } + objectMap["partitionDescription"] = ssp.PartitionDescription + if ssp.ServiceKind != "" { + objectMap["serviceKind"] = ssp.ServiceKind + } + if ssp.PlacementConstraints != nil { + objectMap["placementConstraints"] = ssp.PlacementConstraints + } + if ssp.CorrelationScheme != nil { + objectMap["correlationScheme"] = ssp.CorrelationScheme + } + if ssp.ServiceLoadMetrics != nil { + objectMap["serviceLoadMetrics"] = ssp.ServiceLoadMetrics + } + if ssp.ServicePlacementPolicies != nil { + objectMap["servicePlacementPolicies"] = ssp.ServicePlacementPolicies + } + if ssp.DefaultMoveCost != "" { + objectMap["defaultMoveCost"] = ssp.DefaultMoveCost + } + return json.Marshal(objectMap) +} + +// AsStatefulServiceProperties is the BasicServiceResourceProperties implementation for StatefulServiceProperties. +func (ssp StatefulServiceProperties) AsStatefulServiceProperties() (*StatefulServiceProperties, bool) { + return &ssp, true +} + +// AsStatelessServiceProperties is the BasicServiceResourceProperties implementation for StatefulServiceProperties. +func (ssp StatefulServiceProperties) AsStatelessServiceProperties() (*StatelessServiceProperties, bool) { + return nil, false +} + +// AsServiceResourceProperties is the BasicServiceResourceProperties implementation for StatefulServiceProperties. +func (ssp StatefulServiceProperties) AsServiceResourceProperties() (*ServiceResourceProperties, bool) { + return nil, false +} + +// AsBasicServiceResourceProperties is the BasicServiceResourceProperties implementation for StatefulServiceProperties. +func (ssp StatefulServiceProperties) AsBasicServiceResourceProperties() (BasicServiceResourceProperties, bool) { + return &ssp, true +} + +// UnmarshalJSON is the custom unmarshaler for StatefulServiceProperties struct. +func (ssp *StatefulServiceProperties) 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 "hasPersistedState": + if v != nil { + var hasPersistedState bool + err = json.Unmarshal(*v, &hasPersistedState) + if err != nil { + return err + } + ssp.HasPersistedState = &hasPersistedState + } + case "targetReplicaSetSize": + if v != nil { + var targetReplicaSetSize int32 + err = json.Unmarshal(*v, &targetReplicaSetSize) + if err != nil { + return err + } + ssp.TargetReplicaSetSize = &targetReplicaSetSize + } + case "minReplicaSetSize": + if v != nil { + var minReplicaSetSize int32 + err = json.Unmarshal(*v, &minReplicaSetSize) + if err != nil { + return err + } + ssp.MinReplicaSetSize = &minReplicaSetSize + } + case "replicaRestartWaitDuration": + if v != nil { + var replicaRestartWaitDuration date.Time + err = json.Unmarshal(*v, &replicaRestartWaitDuration) + if err != nil { + return err + } + ssp.ReplicaRestartWaitDuration = &replicaRestartWaitDuration + } + case "quorumLossWaitDuration": + if v != nil { + var quorumLossWaitDuration date.Time + err = json.Unmarshal(*v, &quorumLossWaitDuration) + if err != nil { + return err + } + ssp.QuorumLossWaitDuration = &quorumLossWaitDuration + } + case "standByReplicaKeepDuration": + if v != nil { + var standByReplicaKeepDuration date.Time + err = json.Unmarshal(*v, &standByReplicaKeepDuration) + if err != nil { + return err + } + ssp.StandByReplicaKeepDuration = &standByReplicaKeepDuration + } + case "provisioningState": + if v != nil { + var provisioningState string + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + ssp.ProvisioningState = &provisioningState + } + case "serviceTypeName": + if v != nil { + var serviceTypeName string + err = json.Unmarshal(*v, &serviceTypeName) + if err != nil { + return err + } + ssp.ServiceTypeName = &serviceTypeName + } + case "partitionDescription": + if v != nil { + partitionDescription, err := unmarshalBasicPartitionSchemeDescription(*v) + if err != nil { + return err + } + ssp.PartitionDescription = partitionDescription + } + case "serviceKind": + if v != nil { + var serviceKind ServiceKindBasicServiceResourceProperties + err = json.Unmarshal(*v, &serviceKind) + if err != nil { + return err + } + ssp.ServiceKind = serviceKind + } + case "placementConstraints": + if v != nil { + var placementConstraints string + err = json.Unmarshal(*v, &placementConstraints) + if err != nil { + return err + } + ssp.PlacementConstraints = &placementConstraints + } + case "correlationScheme": + if v != nil { + var correlationScheme []ServiceCorrelationDescription + err = json.Unmarshal(*v, &correlationScheme) + if err != nil { + return err + } + ssp.CorrelationScheme = &correlationScheme + } + case "serviceLoadMetrics": + if v != nil { + var serviceLoadMetrics []ServiceLoadMetricDescription + err = json.Unmarshal(*v, &serviceLoadMetrics) + if err != nil { + return err + } + ssp.ServiceLoadMetrics = &serviceLoadMetrics + } + case "servicePlacementPolicies": + if v != nil { + servicePlacementPolicies, err := unmarshalBasicServicePlacementPolicyDescriptionArray(*v) + if err != nil { + return err + } + ssp.ServicePlacementPolicies = &servicePlacementPolicies + } + case "defaultMoveCost": + if v != nil { + var defaultMoveCost MoveCost + err = json.Unmarshal(*v, &defaultMoveCost) + if err != nil { + return err + } + ssp.DefaultMoveCost = defaultMoveCost + } + } + } + + return nil +} + +// StatefulServiceUpdateProperties the properties of a stateful service resource for patch operations. +type StatefulServiceUpdateProperties struct { + // TargetReplicaSetSize - The target replica set size as a number. + TargetReplicaSetSize *int32 `json:"targetReplicaSetSize,omitempty"` + // MinReplicaSetSize - The minimum replica set size as a number. + MinReplicaSetSize *int32 `json:"minReplicaSetSize,omitempty"` + // ReplicaRestartWaitDuration - The duration between when a replica goes down and when a new replica is created, represented in ISO 8601 format (hh:mm:ss.s). + ReplicaRestartWaitDuration *date.Time `json:"replicaRestartWaitDuration,omitempty"` + // QuorumLossWaitDuration - The maximum duration for which a partition is allowed to be in a state of quorum loss, represented in ISO 8601 format (hh:mm:ss.s). + QuorumLossWaitDuration *date.Time `json:"quorumLossWaitDuration,omitempty"` + // StandByReplicaKeepDuration - The definition on how long StandBy replicas should be maintained before being removed, represented in ISO 8601 format (hh:mm:ss.s). + StandByReplicaKeepDuration *date.Time `json:"standByReplicaKeepDuration,omitempty"` + // ServiceKind - Possible values include: 'ServiceKindBasicServiceResourceUpdatePropertiesServiceKindServiceResourceUpdateProperties', 'ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateful', 'ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateless' + ServiceKind ServiceKindBasicServiceResourceUpdateProperties `json:"serviceKind,omitempty"` + // PlacementConstraints - The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular nodes based on the service requirements. For example, to place a service on nodes where NodeType is blue specify the following: "NodeColor == blue)". + PlacementConstraints *string `json:"placementConstraints,omitempty"` + // CorrelationScheme - A list that describes the correlation of the service with other services. + CorrelationScheme *[]ServiceCorrelationDescription `json:"correlationScheme,omitempty"` + // ServiceLoadMetrics - The service load metrics is given as an array of ServiceLoadMetricDescription objects. + ServiceLoadMetrics *[]ServiceLoadMetricDescription `json:"serviceLoadMetrics,omitempty"` + // ServicePlacementPolicies - A list that describes the correlation of the service with other services. + ServicePlacementPolicies *[]BasicServicePlacementPolicyDescription `json:"servicePlacementPolicies,omitempty"` + // DefaultMoveCost - Specifies the move cost for the service. Possible values include: 'Zero', 'Low', 'Medium', 'High' + DefaultMoveCost MoveCost `json:"defaultMoveCost,omitempty"` +} + +// MarshalJSON is the custom marshaler for StatefulServiceUpdateProperties. +func (ssup StatefulServiceUpdateProperties) MarshalJSON() ([]byte, error) { + ssup.ServiceKind = ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateful + objectMap := make(map[string]interface{}) + if ssup.TargetReplicaSetSize != nil { + objectMap["targetReplicaSetSize"] = ssup.TargetReplicaSetSize + } + if ssup.MinReplicaSetSize != nil { + objectMap["minReplicaSetSize"] = ssup.MinReplicaSetSize + } + if ssup.ReplicaRestartWaitDuration != nil { + objectMap["replicaRestartWaitDuration"] = ssup.ReplicaRestartWaitDuration + } + if ssup.QuorumLossWaitDuration != nil { + objectMap["quorumLossWaitDuration"] = ssup.QuorumLossWaitDuration + } + if ssup.StandByReplicaKeepDuration != nil { + objectMap["standByReplicaKeepDuration"] = ssup.StandByReplicaKeepDuration + } + if ssup.ServiceKind != "" { + objectMap["serviceKind"] = ssup.ServiceKind + } + if ssup.PlacementConstraints != nil { + objectMap["placementConstraints"] = ssup.PlacementConstraints + } + if ssup.CorrelationScheme != nil { + objectMap["correlationScheme"] = ssup.CorrelationScheme + } + if ssup.ServiceLoadMetrics != nil { + objectMap["serviceLoadMetrics"] = ssup.ServiceLoadMetrics + } + if ssup.ServicePlacementPolicies != nil { + objectMap["servicePlacementPolicies"] = ssup.ServicePlacementPolicies + } + if ssup.DefaultMoveCost != "" { + objectMap["defaultMoveCost"] = ssup.DefaultMoveCost + } + return json.Marshal(objectMap) +} + +// AsStatefulServiceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for StatefulServiceUpdateProperties. +func (ssup StatefulServiceUpdateProperties) AsStatefulServiceUpdateProperties() (*StatefulServiceUpdateProperties, bool) { + return &ssup, true +} + +// AsStatelessServiceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for StatefulServiceUpdateProperties. +func (ssup StatefulServiceUpdateProperties) AsStatelessServiceUpdateProperties() (*StatelessServiceUpdateProperties, bool) { + return nil, false +} + +// AsServiceResourceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for StatefulServiceUpdateProperties. +func (ssup StatefulServiceUpdateProperties) AsServiceResourceUpdateProperties() (*ServiceResourceUpdateProperties, bool) { + return nil, false +} + +// AsBasicServiceResourceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for StatefulServiceUpdateProperties. +func (ssup StatefulServiceUpdateProperties) AsBasicServiceResourceUpdateProperties() (BasicServiceResourceUpdateProperties, bool) { + return &ssup, true +} + +// UnmarshalJSON is the custom unmarshaler for StatefulServiceUpdateProperties struct. +func (ssup *StatefulServiceUpdateProperties) 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 "targetReplicaSetSize": + if v != nil { + var targetReplicaSetSize int32 + err = json.Unmarshal(*v, &targetReplicaSetSize) + if err != nil { + return err + } + ssup.TargetReplicaSetSize = &targetReplicaSetSize + } + case "minReplicaSetSize": + if v != nil { + var minReplicaSetSize int32 + err = json.Unmarshal(*v, &minReplicaSetSize) + if err != nil { + return err + } + ssup.MinReplicaSetSize = &minReplicaSetSize + } + case "replicaRestartWaitDuration": + if v != nil { + var replicaRestartWaitDuration date.Time + err = json.Unmarshal(*v, &replicaRestartWaitDuration) + if err != nil { + return err + } + ssup.ReplicaRestartWaitDuration = &replicaRestartWaitDuration + } + case "quorumLossWaitDuration": + if v != nil { + var quorumLossWaitDuration date.Time + err = json.Unmarshal(*v, &quorumLossWaitDuration) + if err != nil { + return err + } + ssup.QuorumLossWaitDuration = &quorumLossWaitDuration + } + case "standByReplicaKeepDuration": + if v != nil { + var standByReplicaKeepDuration date.Time + err = json.Unmarshal(*v, &standByReplicaKeepDuration) + if err != nil { + return err + } + ssup.StandByReplicaKeepDuration = &standByReplicaKeepDuration + } + case "serviceKind": + if v != nil { + var serviceKind ServiceKindBasicServiceResourceUpdateProperties + err = json.Unmarshal(*v, &serviceKind) + if err != nil { + return err + } + ssup.ServiceKind = serviceKind + } + case "placementConstraints": + if v != nil { + var placementConstraints string + err = json.Unmarshal(*v, &placementConstraints) + if err != nil { + return err + } + ssup.PlacementConstraints = &placementConstraints + } + case "correlationScheme": + if v != nil { + var correlationScheme []ServiceCorrelationDescription + err = json.Unmarshal(*v, &correlationScheme) + if err != nil { + return err + } + ssup.CorrelationScheme = &correlationScheme + } + case "serviceLoadMetrics": + if v != nil { + var serviceLoadMetrics []ServiceLoadMetricDescription + err = json.Unmarshal(*v, &serviceLoadMetrics) + if err != nil { + return err + } + ssup.ServiceLoadMetrics = &serviceLoadMetrics + } + case "servicePlacementPolicies": + if v != nil { + servicePlacementPolicies, err := unmarshalBasicServicePlacementPolicyDescriptionArray(*v) + if err != nil { + return err + } + ssup.ServicePlacementPolicies = &servicePlacementPolicies + } + case "defaultMoveCost": + if v != nil { + var defaultMoveCost MoveCost + err = json.Unmarshal(*v, &defaultMoveCost) + if err != nil { + return err + } + ssup.DefaultMoveCost = defaultMoveCost + } + } + } + + return nil +} + +// StatelessServiceProperties the properties of a stateless service resource. +type StatelessServiceProperties struct { + // InstanceCount - The instance count. + InstanceCount *int32 `json:"instanceCount,omitempty"` + // ProvisioningState - The current deployment or provisioning state, which only appears in the response + ProvisioningState *string `json:"provisioningState,omitempty"` + // ServiceTypeName - The name of the service type + ServiceTypeName *string `json:"serviceTypeName,omitempty"` + // PartitionDescription - Describes how the service is partitioned. + PartitionDescription BasicPartitionSchemeDescription `json:"partitionDescription,omitempty"` + // ServiceKind - Possible values include: 'ServiceKindServiceResourceProperties', 'ServiceKindStateful1', 'ServiceKindStateless1' + ServiceKind ServiceKindBasicServiceResourceProperties `json:"serviceKind,omitempty"` + // PlacementConstraints - The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular nodes based on the service requirements. For example, to place a service on nodes where NodeType is blue specify the following: "NodeColor == blue)". + PlacementConstraints *string `json:"placementConstraints,omitempty"` + // CorrelationScheme - A list that describes the correlation of the service with other services. + CorrelationScheme *[]ServiceCorrelationDescription `json:"correlationScheme,omitempty"` + // ServiceLoadMetrics - The service load metrics is given as an array of ServiceLoadMetricDescription objects. + ServiceLoadMetrics *[]ServiceLoadMetricDescription `json:"serviceLoadMetrics,omitempty"` + // ServicePlacementPolicies - A list that describes the correlation of the service with other services. + ServicePlacementPolicies *[]BasicServicePlacementPolicyDescription `json:"servicePlacementPolicies,omitempty"` + // DefaultMoveCost - Specifies the move cost for the service. Possible values include: 'Zero', 'Low', 'Medium', 'High' + DefaultMoveCost MoveCost `json:"defaultMoveCost,omitempty"` +} + +// MarshalJSON is the custom marshaler for StatelessServiceProperties. +func (ssp StatelessServiceProperties) MarshalJSON() ([]byte, error) { + ssp.ServiceKind = ServiceKindStateless1 + objectMap := make(map[string]interface{}) + if ssp.InstanceCount != nil { + objectMap["instanceCount"] = ssp.InstanceCount + } + if ssp.ProvisioningState != nil { + objectMap["provisioningState"] = ssp.ProvisioningState + } + if ssp.ServiceTypeName != nil { + objectMap["serviceTypeName"] = ssp.ServiceTypeName + } + objectMap["partitionDescription"] = ssp.PartitionDescription + if ssp.ServiceKind != "" { + objectMap["serviceKind"] = ssp.ServiceKind + } + if ssp.PlacementConstraints != nil { + objectMap["placementConstraints"] = ssp.PlacementConstraints + } + if ssp.CorrelationScheme != nil { + objectMap["correlationScheme"] = ssp.CorrelationScheme + } + if ssp.ServiceLoadMetrics != nil { + objectMap["serviceLoadMetrics"] = ssp.ServiceLoadMetrics + } + if ssp.ServicePlacementPolicies != nil { + objectMap["servicePlacementPolicies"] = ssp.ServicePlacementPolicies + } + if ssp.DefaultMoveCost != "" { + objectMap["defaultMoveCost"] = ssp.DefaultMoveCost + } + return json.Marshal(objectMap) +} + +// AsStatefulServiceProperties is the BasicServiceResourceProperties implementation for StatelessServiceProperties. +func (ssp StatelessServiceProperties) AsStatefulServiceProperties() (*StatefulServiceProperties, bool) { + return nil, false +} + +// AsStatelessServiceProperties is the BasicServiceResourceProperties implementation for StatelessServiceProperties. +func (ssp StatelessServiceProperties) AsStatelessServiceProperties() (*StatelessServiceProperties, bool) { + return &ssp, true +} + +// AsServiceResourceProperties is the BasicServiceResourceProperties implementation for StatelessServiceProperties. +func (ssp StatelessServiceProperties) AsServiceResourceProperties() (*ServiceResourceProperties, bool) { + return nil, false +} + +// AsBasicServiceResourceProperties is the BasicServiceResourceProperties implementation for StatelessServiceProperties. +func (ssp StatelessServiceProperties) AsBasicServiceResourceProperties() (BasicServiceResourceProperties, bool) { + return &ssp, true +} + +// UnmarshalJSON is the custom unmarshaler for StatelessServiceProperties struct. +func (ssp *StatelessServiceProperties) 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 "instanceCount": + if v != nil { + var instanceCount int32 + err = json.Unmarshal(*v, &instanceCount) + if err != nil { + return err + } + ssp.InstanceCount = &instanceCount + } + case "provisioningState": + if v != nil { + var provisioningState string + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + ssp.ProvisioningState = &provisioningState + } + case "serviceTypeName": + if v != nil { + var serviceTypeName string + err = json.Unmarshal(*v, &serviceTypeName) + if err != nil { + return err + } + ssp.ServiceTypeName = &serviceTypeName + } + case "partitionDescription": + if v != nil { + partitionDescription, err := unmarshalBasicPartitionSchemeDescription(*v) + if err != nil { + return err + } + ssp.PartitionDescription = partitionDescription + } + case "serviceKind": + if v != nil { + var serviceKind ServiceKindBasicServiceResourceProperties + err = json.Unmarshal(*v, &serviceKind) + if err != nil { + return err + } + ssp.ServiceKind = serviceKind + } + case "placementConstraints": + if v != nil { + var placementConstraints string + err = json.Unmarshal(*v, &placementConstraints) + if err != nil { + return err + } + ssp.PlacementConstraints = &placementConstraints + } + case "correlationScheme": + if v != nil { + var correlationScheme []ServiceCorrelationDescription + err = json.Unmarshal(*v, &correlationScheme) + if err != nil { + return err + } + ssp.CorrelationScheme = &correlationScheme + } + case "serviceLoadMetrics": + if v != nil { + var serviceLoadMetrics []ServiceLoadMetricDescription + err = json.Unmarshal(*v, &serviceLoadMetrics) + if err != nil { + return err + } + ssp.ServiceLoadMetrics = &serviceLoadMetrics + } + case "servicePlacementPolicies": + if v != nil { + servicePlacementPolicies, err := unmarshalBasicServicePlacementPolicyDescriptionArray(*v) + if err != nil { + return err + } + ssp.ServicePlacementPolicies = &servicePlacementPolicies + } + case "defaultMoveCost": + if v != nil { + var defaultMoveCost MoveCost + err = json.Unmarshal(*v, &defaultMoveCost) + if err != nil { + return err + } + ssp.DefaultMoveCost = defaultMoveCost + } + } + } + + return nil +} + +// StatelessServiceUpdateProperties the properties of a stateless service resource for patch operations. +type StatelessServiceUpdateProperties struct { + // InstanceCount - The instance count. + InstanceCount *int32 `json:"instanceCount,omitempty"` + // ServiceKind - Possible values include: 'ServiceKindBasicServiceResourceUpdatePropertiesServiceKindServiceResourceUpdateProperties', 'ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateful', 'ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateless' + ServiceKind ServiceKindBasicServiceResourceUpdateProperties `json:"serviceKind,omitempty"` + // PlacementConstraints - The placement constraints as a string. Placement constraints are boolean expressions on node properties and allow for restricting a service to particular nodes based on the service requirements. For example, to place a service on nodes where NodeType is blue specify the following: "NodeColor == blue)". + PlacementConstraints *string `json:"placementConstraints,omitempty"` + // CorrelationScheme - A list that describes the correlation of the service with other services. + CorrelationScheme *[]ServiceCorrelationDescription `json:"correlationScheme,omitempty"` + // ServiceLoadMetrics - The service load metrics is given as an array of ServiceLoadMetricDescription objects. + ServiceLoadMetrics *[]ServiceLoadMetricDescription `json:"serviceLoadMetrics,omitempty"` + // ServicePlacementPolicies - A list that describes the correlation of the service with other services. + ServicePlacementPolicies *[]BasicServicePlacementPolicyDescription `json:"servicePlacementPolicies,omitempty"` + // DefaultMoveCost - Specifies the move cost for the service. Possible values include: 'Zero', 'Low', 'Medium', 'High' + DefaultMoveCost MoveCost `json:"defaultMoveCost,omitempty"` +} + +// MarshalJSON is the custom marshaler for StatelessServiceUpdateProperties. +func (ssup StatelessServiceUpdateProperties) MarshalJSON() ([]byte, error) { + ssup.ServiceKind = ServiceKindBasicServiceResourceUpdatePropertiesServiceKindStateless + objectMap := make(map[string]interface{}) + if ssup.InstanceCount != nil { + objectMap["instanceCount"] = ssup.InstanceCount + } + if ssup.ServiceKind != "" { + objectMap["serviceKind"] = ssup.ServiceKind + } + if ssup.PlacementConstraints != nil { + objectMap["placementConstraints"] = ssup.PlacementConstraints + } + if ssup.CorrelationScheme != nil { + objectMap["correlationScheme"] = ssup.CorrelationScheme + } + if ssup.ServiceLoadMetrics != nil { + objectMap["serviceLoadMetrics"] = ssup.ServiceLoadMetrics + } + if ssup.ServicePlacementPolicies != nil { + objectMap["servicePlacementPolicies"] = ssup.ServicePlacementPolicies + } + if ssup.DefaultMoveCost != "" { + objectMap["defaultMoveCost"] = ssup.DefaultMoveCost + } + return json.Marshal(objectMap) +} + +// AsStatefulServiceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for StatelessServiceUpdateProperties. +func (ssup StatelessServiceUpdateProperties) AsStatefulServiceUpdateProperties() (*StatefulServiceUpdateProperties, bool) { + return nil, false +} + +// AsStatelessServiceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for StatelessServiceUpdateProperties. +func (ssup StatelessServiceUpdateProperties) AsStatelessServiceUpdateProperties() (*StatelessServiceUpdateProperties, bool) { + return &ssup, true +} + +// AsServiceResourceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for StatelessServiceUpdateProperties. +func (ssup StatelessServiceUpdateProperties) AsServiceResourceUpdateProperties() (*ServiceResourceUpdateProperties, bool) { + return nil, false +} + +// AsBasicServiceResourceUpdateProperties is the BasicServiceResourceUpdateProperties implementation for StatelessServiceUpdateProperties. +func (ssup StatelessServiceUpdateProperties) AsBasicServiceResourceUpdateProperties() (BasicServiceResourceUpdateProperties, bool) { + return &ssup, true +} + +// UnmarshalJSON is the custom unmarshaler for StatelessServiceUpdateProperties struct. +func (ssup *StatelessServiceUpdateProperties) 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 "instanceCount": + if v != nil { + var instanceCount int32 + err = json.Unmarshal(*v, &instanceCount) + if err != nil { + return err + } + ssup.InstanceCount = &instanceCount + } + case "serviceKind": + if v != nil { + var serviceKind ServiceKindBasicServiceResourceUpdateProperties + err = json.Unmarshal(*v, &serviceKind) + if err != nil { + return err + } + ssup.ServiceKind = serviceKind + } + case "placementConstraints": + if v != nil { + var placementConstraints string + err = json.Unmarshal(*v, &placementConstraints) + if err != nil { + return err + } + ssup.PlacementConstraints = &placementConstraints + } + case "correlationScheme": + if v != nil { + var correlationScheme []ServiceCorrelationDescription + err = json.Unmarshal(*v, &correlationScheme) + if err != nil { + return err + } + ssup.CorrelationScheme = &correlationScheme + } + case "serviceLoadMetrics": + if v != nil { + var serviceLoadMetrics []ServiceLoadMetricDescription + err = json.Unmarshal(*v, &serviceLoadMetrics) + if err != nil { + return err + } + ssup.ServiceLoadMetrics = &serviceLoadMetrics + } + case "servicePlacementPolicies": + if v != nil { + servicePlacementPolicies, err := unmarshalBasicServicePlacementPolicyDescriptionArray(*v) + if err != nil { + return err + } + ssup.ServicePlacementPolicies = &servicePlacementPolicies + } + case "defaultMoveCost": + if v != nil { + var defaultMoveCost MoveCost + err = json.Unmarshal(*v, &defaultMoveCost) + if err != nil { + return err + } + ssup.DefaultMoveCost = defaultMoveCost + } + } + } + + return nil +} + +// UniformInt64RangePartitionSchemeDescription describes a partitioning scheme where an integer range is allocated +// evenly across a number of partitions. +type UniformInt64RangePartitionSchemeDescription struct { + // Count - The number of partitions. + Count *int32 `json:"Count,omitempty"` + // LowKey - String indicating the lower bound of the partition key range that + // should be split between the partition ‘Count’ + LowKey *string `json:"LowKey,omitempty"` + // HighKey - String indicating the upper bound of the partition key range that + // should be split between the partition ‘Count’ + HighKey *string `json:"HighKey,omitempty"` + // PartitionScheme - Possible values include: 'PartitionSchemePartitionSchemeDescription', 'PartitionSchemeNamed', 'PartitionSchemeSingleton', 'PartitionSchemeUniformInt64Range' + PartitionScheme PartitionSchemeBasicPartitionSchemeDescription `json:"PartitionScheme,omitempty"` +} + +// MarshalJSON is the custom marshaler for UniformInt64RangePartitionSchemeDescription. +func (ui6rpsd UniformInt64RangePartitionSchemeDescription) MarshalJSON() ([]byte, error) { + ui6rpsd.PartitionScheme = PartitionSchemeUniformInt64Range + objectMap := make(map[string]interface{}) + if ui6rpsd.Count != nil { + objectMap["Count"] = ui6rpsd.Count + } + if ui6rpsd.LowKey != nil { + objectMap["LowKey"] = ui6rpsd.LowKey + } + if ui6rpsd.HighKey != nil { + objectMap["HighKey"] = ui6rpsd.HighKey + } + if ui6rpsd.PartitionScheme != "" { + objectMap["PartitionScheme"] = ui6rpsd.PartitionScheme + } + return json.Marshal(objectMap) +} + +// AsNamedPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for UniformInt64RangePartitionSchemeDescription. +func (ui6rpsd UniformInt64RangePartitionSchemeDescription) AsNamedPartitionSchemeDescription() (*NamedPartitionSchemeDescription, bool) { + return nil, false +} + +// AsSingletonPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for UniformInt64RangePartitionSchemeDescription. +func (ui6rpsd UniformInt64RangePartitionSchemeDescription) AsSingletonPartitionSchemeDescription() (*SingletonPartitionSchemeDescription, bool) { + return nil, false +} + +// AsUniformInt64RangePartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for UniformInt64RangePartitionSchemeDescription. +func (ui6rpsd UniformInt64RangePartitionSchemeDescription) AsUniformInt64RangePartitionSchemeDescription() (*UniformInt64RangePartitionSchemeDescription, bool) { + return &ui6rpsd, true +} + +// AsPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for UniformInt64RangePartitionSchemeDescription. +func (ui6rpsd UniformInt64RangePartitionSchemeDescription) AsPartitionSchemeDescription() (*PartitionSchemeDescription, bool) { + return nil, false +} + +// AsBasicPartitionSchemeDescription is the BasicPartitionSchemeDescription implementation for UniformInt64RangePartitionSchemeDescription. +func (ui6rpsd UniformInt64RangePartitionSchemeDescription) AsBasicPartitionSchemeDescription() (BasicPartitionSchemeDescription, bool) { + return &ui6rpsd, true +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/operations.go new file mode 100644 index 0000000000000..617b66ddc49e3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/operations.go @@ -0,0 +1,126 @@ +package servicefabric + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the service Fabric 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. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the list of available Service Fabric resource provider API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.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, "servicefabric.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.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 = "" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ServiceFabric/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 autorest.SendWithSender(client, 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(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "servicefabric.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, "servicefabric.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.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) { + result.page, err = client.List(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/services.go b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/services.go new file mode 100644 index 0000000000000..8cbc4ffed22e4 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/services.go @@ -0,0 +1,412 @@ +package servicefabric + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ServicesClient is the service Fabric Management Client +type ServicesClient struct { + BaseClient +} + +// NewServicesClient creates an instance of the ServicesClient client. +func NewServicesClient(subscriptionID string) ServicesClient { + return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServicesClientWithBaseURI creates an instance of the ServicesClient client. +func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient { + return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create or update a Service Fabric service resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationName - the name of the application resource. +// serviceName - the name of the service resource in the format of {applicationName}~{serviceName}. +// parameters - the service resource. +func (client ServicesClient) Create(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, serviceName string, parameters ServiceResource) (result ServicesCreateFuture, err error) { + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, applicationName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ServicesClient) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, serviceName string, parameters ServiceResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}", pathParameters), + autorest.WithJSON(parameters), + 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 ServicesClient) CreateSender(req *http.Request) (future ServicesCreateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ServicesClient) CreateResponder(resp *http.Response) (result ServiceResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a Service Fabric service resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationName - the name of the application resource. +// serviceName - the name of the service resource in the format of {applicationName}~{serviceName}. +func (client ServicesClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, serviceName string) (result ServicesDeleteFuture, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, applicationName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}", 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 ServicesClient) DeleteSender(req *http.Request) (future ServicesDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServicesClient) 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 a Service Fabric service resource created or in the process of being created in the Service Fabric +// application resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationName - the name of the application resource. +// serviceName - the name of the service resource in the format of {applicationName}~{serviceName}. +func (client ServicesClient) Get(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, serviceName string) (result ServiceResource, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, clusterName, applicationName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}", 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 ServicesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServicesClient) GetResponder(resp *http.Response) (result ServiceResource, 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 all service resources created or in the process of being created in the Service Fabric application +// resource. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationName - the name of the application resource. +func (client ServicesClient) List(ctx context.Context, resourceGroupName string, clusterName string, applicationName string) (result ServiceResourceList, err error) { + req, err := client.ListPreparer(ctx, resourceGroupName, clusterName, applicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ServicesClient) ListPreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-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.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/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 ServicesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServicesClient) ListResponder(resp *http.Response) (result ServiceResourceList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update a Service Fabric service resource with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the cluster resource. +// applicationName - the name of the application resource. +// serviceName - the name of the service resource in the format of {applicationName}~{serviceName}. +// parameters - the service resource for patch operations. +func (client ServicesClient) Update(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, serviceName string, parameters ServiceResourceUpdate) (result ServicesUpdateFuture, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, applicationName, serviceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "servicefabric.ServicesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, serviceName string, parameters ServiceResourceUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applicationName": autorest.Encode("path", applicationName), + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applications/{applicationName}/services/{serviceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) UpdateSender(req *http.Request) (future ServicesUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServicesClient) UpdateResponder(resp *http.Response) (result ServiceResourceUpdate, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/version.go new file mode 100644 index 0000000000000..9f2d3bd80f534 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric/version.go @@ -0,0 +1,30 @@ +package servicefabric + +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 + " servicefabric/2018-02-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 1e4a85db7d02f..18a13188cfe31 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -66,20 +66,20 @@ "version": "=v18.0.0", "versionExact": "v18.0.0" }, + { + "checksumSHA1": "9oNfXIzF5S8ninqAOSfpVf5rNEY=", + "path": "github.com/Azure/azure-sdk-for-go/services/datalake/analytics/mgmt/2016-11-01/account", + "revision": "fbe7db0e3f9793ba3e5704efbab84f51436c136e", + "revisionTime": "2018-07-03T19:15:42Z", + "version": "=v18.0.0", + "versionExact": "v18.0.0" + }, { "checksumSHA1": "owtUC3Li102StpaZ1Ahh0SvifP4=", "path": "github.com/Azure/azure-sdk-for-go/services/datalake/store/2016-11-01/filesystem", "revision": "fbe7db0e3f9793ba3e5704efbab84f51436c136e", "revisionTime": "2018-07-03T19:15:42Z", "version": "v18.0.0", - "versionExact": "v18.0.0" - }, - { - "checksumSHA1": "9oNfXIzF5S8ninqAOSfpVf5rNEY=", - "path": "github.com/Azure/azure-sdk-for-go/services/datalake/analytics/mgmt/2016-11-01/account", - "revision": "fbe7db0e3f9793ba3e5704efbab84f51436c136e", - "revisionTime": "2018-07-03T19:15:42Z", - "version": "=v18.0.0", "versionExact": "v18.0.0" }, { @@ -314,6 +314,14 @@ "version": "=v18.0.0", "versionExact": "v18.0.0" }, + { + "checksumSHA1": "E6K9qLJIuos/ZGzhOpfbCxb77MQ=", + "path": "github.com/Azure/azure-sdk-for-go/services/servicefabric/mgmt/2018-02-01/servicefabric", + "revision": "fbe7db0e3f9793ba3e5704efbab84f51436c136e", + "revisionTime": "2018-07-03T19:15:42Z", + "version": "=v18.0.0", + "versionExact": "v18.0.0" + }, { "checksumSHA1": "ySkjHczHi2zN8B1TuWfvKVLGetw=", "path": "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage", diff --git a/website/azurerm.erb b/website/azurerm.erb index 8b2cae61c36af..3e9e9256ba3f5 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -857,6 +857,15 @@ + > + Service Fabric Resources + + + > Storage Resources