• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang azure.String函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/jen20/riviera/azure.String函数的典型用法代码示例。如果您正苦于以下问题:Golang String函数的具体用法?Golang String怎么用?Golang String使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了String函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: createResourceGroup

func createResourceGroup(azureClient *azure.Client) (string, error) {
	name := fmt.Sprintf("riviera_resource_group_%d", rand.Intn(8999)+1000)

	r := azureClient.NewRequest()

	r.Command = azure.CreateResourceGroup{
		Name:     name,
		Location: azure.WestUS,
		Tags: map[string]*string{
			"Key1": azure.String("value1"),
			"Key2": azure.String("value2"),
		},
	}

	response, err := r.Execute()
	if err != nil {
		return "", err
	}

	if !response.IsSuccessful() {
		return "", fmt.Errorf("Error creating resource group %q", name)
	}

	return name, nil
}
开发者ID:jen20,项目名称:riviera,代码行数:25,代码来源:main.go


示例2: main

func main() {
	// 1 - Configure the ARM Client with credentials
	creds := &azure.AzureResourceManagerCredentials{
		ClientID:       os.Getenv("ARM_CLIENT_ID"),
		ClientSecret:   os.Getenv("ARM_CLIENT_SECRET"),
		TenantID:       os.Getenv("ARM_TENANT_ID"),
		SubscriptionID: os.Getenv("ARM_SUBSCRIPTION_ID"),
	}

	azureClient, err := azure.NewClient(creds)
	if err != nil {
		log.Fatal(err)
	}

	// 2 - Create a new request with a location attached
	r := azureClient.NewRequest()

	// 3 - Create a command object, and assign it to the request
	r.Command = azure.CreateResourceGroup{
		Name:     resourceGroupName,
		Location: azure.WestUS,
		Tags: map[string]*string{
			"Key1": azure.String("value1"),
			"Key2": azure.String("value2"),
		},
	}

	// 4 - Execute the command
	response, err := r.Execute()
	if err != nil {
		log.Fatal(err)
	}

	// 5 - Make use of the result
	if response.IsSuccessful() {
		result := response.Parsed.(*azure.CreateResourceGroupResponse)
		fmt.Printf("Created resource group %q:\n", *result.Name)
		fmt.Printf("\tID: %s\n", *result.ID)
		fmt.Printf("\tLocation: %s\n", *result.Location)
		fmt.Printf("\tProvisioningState: %s\n", *result.ProvisioningState)
	} else {
		log.Fatalf("Failed creating resource group: %s", response.Error.Error())
	}

	// 6 - Delete the resource group
	d := azureClient.NewRequest()
	d.Command = azure.DeleteResourceGroup{
		Name: resourceGroupName,
	}
	deleteResponse, err := d.Execute()
	if err != nil {
		log.Fatal(err)
	}
	if deleteResponse.IsSuccessful() {
		log.Printf("Successfully deleted resource group %q", resourceGroupName)
	} else {
		log.Printf("Error deleting resource group %q", resourceGroupName)
	}
}
开发者ID:jen20,项目名称:riviera,代码行数:59,代码来源:main.go


示例3: resourceArmLoadBalancerCreate

func resourceArmLoadBalancerCreate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*ArmClient)
	loadBalancerClient := client.loadBalancerClient

	log.Printf("[INFO] preparing arguments for Azure ARM LoadBalancer creation.")

	name := d.Get("name").(string)
	location := d.Get("location").(string)
	resGroup := d.Get("resource_group_name").(string)
	tags := d.Get("tags").(map[string]interface{})
	expandedTags := expandTags(tags)

	properties := network.LoadBalancerPropertiesFormat{}

	if _, ok := d.GetOk("frontend_ip_configuration"); ok {
		properties.FrontendIPConfigurations = expandAzureRmLoadBalancerFrontendIpConfigurations(d)
	}

	loadbalancer := network.LoadBalancer{
		Name:       azure.String(name),
		Location:   azure.String(location),
		Tags:       expandedTags,
		Properties: &properties,
	}

	_, err := loadBalancerClient.CreateOrUpdate(resGroup, name, loadbalancer, make(chan struct{}))
	if err != nil {
		return errwrap.Wrapf("Error Creating/Updating LoadBalancer {{err}}", err)
	}

	read, err := loadBalancerClient.Get(resGroup, name, "")
	if err != nil {
		return errwrap.Wrapf("Error Getting LoadBalancer {{err}", err)
	}
	if read.ID == nil {
		return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", name, resGroup)
	}

	d.SetId(*read.ID)

	log.Printf("[DEBUG] Waiting for LoadBalancer (%s) to become available", name)
	stateConf := &resource.StateChangeConf{
		Pending: []string{"Accepted", "Updating"},
		Target:  []string{"Succeeded"},
		Refresh: loadbalancerStateRefreshFunc(client, resGroup, name),
		Timeout: 10 * time.Minute,
	}
	if _, err := stateConf.WaitForState(); err != nil {
		return fmt.Errorf("Error waiting for LoadBalancer (%s) to become available: %s", name, err)
	}

	return resourecArmLoadBalancerRead(d, meta)
}
开发者ID:paultyng,项目名称:terraform,代码行数:53,代码来源:resource_arm_loadbalancer.go


示例4: expandAzureRmLoadBalancerNatRule

func expandAzureRmLoadBalancerNatRule(d *schema.ResourceData, lb *network.LoadBalancer) (*network.InboundNatRule, error) {

	properties := network.InboundNatRulePropertiesFormat{
		Protocol:     network.TransportProtocol(d.Get("protocol").(string)),
		FrontendPort: azure.Int32(int32(d.Get("frontend_port").(int))),
		BackendPort:  azure.Int32(int32(d.Get("backend_port").(int))),
	}

	if v := d.Get("frontend_ip_configuration_name").(string); v != "" {
		rule, _, exists := findLoadBalancerFrontEndIpConfigurationByName(lb, v)
		if !exists {
			return nil, fmt.Errorf("[ERROR] Cannot find FrontEnd IP Configuration with the name %s", v)
		}

		feip := network.SubResource{
			ID: rule.ID,
		}

		properties.FrontendIPConfiguration = &feip
	}

	natRule := network.InboundNatRule{
		Name:       azure.String(d.Get("name").(string)),
		Properties: &properties,
	}

	return &natRule, nil
}
开发者ID:paultyng,项目名称:terraform,代码行数:28,代码来源:resource_arm_loadbalancer_nat_rule.go


示例5: resourceArmContainerRegistryCreate

func resourceArmContainerRegistryCreate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*ArmClient).containerRegistryClient
	log.Printf("[INFO] preparing arguments for AzureRM Container Registry creation.")

	resourceGroup := d.Get("resource_group_name").(string)
	name := d.Get("name").(string)
	location := d.Get("location").(string)

	adminUserEnabled := d.Get("admin_enabled").(bool)
	tags := d.Get("tags").(map[string]interface{})

	parameters := containerregistry.Registry{
		Location: &location,
		RegistryProperties: &containerregistry.RegistryProperties{
			AdminUserEnabled: &adminUserEnabled,
		},
		Tags: expandTags(tags),
	}

	accounts := d.Get("storage_account").(*schema.Set).List()
	account := accounts[0].(map[string]interface{})
	storageAccountName := account["name"].(string)
	storageAccountAccessKey := account["access_key"].(string)
	parameters.RegistryProperties.StorageAccount = &containerregistry.StorageAccountProperties{
		Name:      azure.String(storageAccountName),
		AccessKey: azure.String(storageAccountAccessKey),
	}

	_, err := client.CreateOrUpdate(resourceGroup, name, parameters)
	if err != nil {
		return err
	}

	read, err := client.GetProperties(resourceGroup, name)
	if err != nil {
		return err
	}

	if read.ID == nil {
		return fmt.Errorf("Cannot read Container Registry %s (resource group %s) ID", name, resourceGroup)
	}

	d.SetId(*read.ID)

	return resourceArmContainerRegistryRead(d, meta)
}
开发者ID:hashicorp,项目名称:terraform,代码行数:46,代码来源:resource_arm_container_registry.go


示例6: resourceArmSqlServerCreate

func resourceArmSqlServerCreate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*ArmClient)
	rivieraClient := client.rivieraClient

	tags := d.Get("tags").(map[string]interface{})
	expandedTags := expandTags(tags)

	createRequest := rivieraClient.NewRequest()
	createRequest.Command = &sql.CreateOrUpdateServer{
		Name:                       d.Get("name").(string),
		Location:                   d.Get("location").(string),
		ResourceGroupName:          d.Get("resource_group_name").(string),
		AdministratorLogin:         azure.String(d.Get("administrator_login").(string)),
		AdministratorLoginPassword: azure.String(d.Get("administrator_login_password").(string)),
		Version:                    azure.String(d.Get("version").(string)),
		Tags:                       *expandedTags,
	}

	createResponse, err := createRequest.Execute()
	if err != nil {
		return fmt.Errorf("Error creating SQL Server: %s", err)
	}
	if !createResponse.IsSuccessful() {
		return fmt.Errorf("Error creating SQL Server: %s", createResponse.Error)
	}

	readRequest := rivieraClient.NewRequest()
	readRequest.Command = &sql.GetServer{
		Name:              d.Get("name").(string),
		ResourceGroupName: d.Get("resource_group_name").(string),
	}

	readResponse, err := readRequest.Execute()
	if err != nil {
		return fmt.Errorf("Error reading SQL Server: %s", err)
	}
	if !readResponse.IsSuccessful() {
		return fmt.Errorf("Error reading SQL Server: %s", readResponse.Error)
	}

	resp := readResponse.Parsed.(*sql.GetServerResponse)
	d.SetId(*resp.ID)

	return resourceArmSqlServerRead(d, meta)
}
开发者ID:RezaDKhan,项目名称:terraform,代码行数:45,代码来源:resource_arm_sql_server.go


示例7: setup

func setup(t *testing.T, conf map[string]string) {
	creds, err := getCredentialsFromConf(conf)
	if err != nil {
		t.Fatalf("Error getting credentials from conf: %v", err)
	}
	rivieraClient, err := getRivieraClient(creds)
	if err != nil {
		t.Fatalf("Error instantiating the riviera client: %v", err)
	}

	// Create resource group
	r := rivieraClient.NewRequest()
	r.Command = riviera.CreateResourceGroup{
		Name:     conf["resource_group_name"],
		Location: riviera.WestUS,
	}
	response, err := r.Execute()
	if err != nil {
		t.Fatalf("Error creating a resource group: %v", err)
	}
	if !response.IsSuccessful() {
		t.Fatalf("Error creating a resource group: %v", response.Error.Error())
	}

	// Create storage account
	r = rivieraClient.NewRequest()
	r.Command = storage.CreateStorageAccount{
		ResourceGroupName: conf["resource_group_name"],
		Name:              conf["storage_account_name"],
		AccountType:       riviera.String("Standard_LRS"),
		Location:          riviera.WestUS,
	}
	response, err = r.Execute()
	if err != nil {
		t.Fatalf("Error creating a storage account: %v", err)
	}
	if !response.IsSuccessful() {
		t.Fatalf("Error creating a storage account: %v", response.Error.Error())
	}

	// Create container
	accessKey, err := getStorageAccountAccessKey(conf, conf["resource_group_name"], conf["storage_account_name"])
	if err != nil {
		t.Fatalf("Error creating a storage account: %v", err)
	}
	storageClient, err := mainStorage.NewBasicClient(conf["storage_account_name"], accessKey)
	if err != nil {
		t.Fatalf("Error creating storage client for storage account %q: %s", conf["storage_account_name"], err)
	}
	blobClient := storageClient.GetBlobService()
	_, err = blobClient.CreateContainerIfNotExists(conf["container_name"], mainStorage.ContainerAccessTypePrivate)
	if err != nil {
		t.Fatalf("Couldn't create container with name %s: %s.", conf["container_name"], err)
	}
}
开发者ID:Originate,项目名称:terraform,代码行数:55,代码来源:azure_test.go


示例8: resourceArmSqlFirewallRuleCreate

func resourceArmSqlFirewallRuleCreate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*ArmClient)
	rivieraClient := client.rivieraClient

	createRequest := rivieraClient.NewRequest()
	createRequest.Command = &sql.CreateOrUpdateFirewallRule{
		Name:              d.Get("name").(string),
		ResourceGroupName: d.Get("resource_group_name").(string),
		ServerName:        d.Get("server_name").(string),
		StartIPAddress:    azure.String(d.Get("start_ip_address").(string)),
		EndIPAddress:      azure.String(d.Get("end_ip_address").(string)),
	}

	createResponse, err := createRequest.Execute()
	if err != nil {
		return fmt.Errorf("Error creating SQL Server Firewall Rule: %s", err)
	}
	if !createResponse.IsSuccessful() {
		return fmt.Errorf("Error creating SQL Server Firewall Rule: %s", createResponse.Error)
	}

	readRequest := rivieraClient.NewRequest()
	readRequest.Command = &sql.GetFirewallRule{
		Name:              d.Get("name").(string),
		ResourceGroupName: d.Get("resource_group_name").(string),
		ServerName:        d.Get("server_name").(string),
	}

	readResponse, err := readRequest.Execute()
	if err != nil {
		return fmt.Errorf("Error reading SQL Server Firewall Rule: %s", err)
	}
	if !readResponse.IsSuccessful() {
		return fmt.Errorf("Error reading SQL Server Firewall Rule: %s", readResponse.Error)
	}

	resp := readResponse.Parsed.(*sql.GetFirewallRuleResponse)
	d.SetId(*resp.ID)

	return resourceArmSqlFirewallRuleRead(d, meta)
}
开发者ID:chandy,项目名称:terraform,代码行数:41,代码来源:resource_arm_sql_firewall_rule.go


示例9: expandAzureRmLoadBalancerRule

func expandAzureRmLoadBalancerRule(d *schema.ResourceData, lb *network.LoadBalancer) (*network.LoadBalancingRule, error) {

	properties := network.LoadBalancingRulePropertiesFormat{
		Protocol:         network.TransportProtocol(d.Get("protocol").(string)),
		FrontendPort:     azure.Int32(int32(d.Get("frontend_port").(int))),
		BackendPort:      azure.Int32(int32(d.Get("backend_port").(int))),
		EnableFloatingIP: azure.Bool(d.Get("enable_floating_ip").(bool)),
	}

	if v, ok := d.GetOk("idle_timeout_in_minutes"); ok {
		properties.IdleTimeoutInMinutes = azure.Int32(int32(v.(int)))
	}

	if v := d.Get("load_distribution").(string); v != "" {
		properties.LoadDistribution = network.LoadDistribution(v)
	}

	if v := d.Get("frontend_ip_configuration_name").(string); v != "" {
		rule, _, exists := findLoadBalancerFrontEndIpConfigurationByName(lb, v)
		if !exists {
			return nil, fmt.Errorf("[ERROR] Cannot find FrontEnd IP Configuration with the name %s", v)
		}

		feip := network.SubResource{
			ID: rule.ID,
		}

		properties.FrontendIPConfiguration = &feip
	}

	if v := d.Get("backend_address_pool_id").(string); v != "" {
		beAP := network.SubResource{
			ID: &v,
		}

		properties.BackendAddressPool = &beAP
	}

	if v := d.Get("probe_id").(string); v != "" {
		pid := network.SubResource{
			ID: &v,
		}

		properties.Probe = &pid
	}

	lbRule := network.LoadBalancingRule{
		Name: azure.String(d.Get("name").(string)),
		LoadBalancingRulePropertiesFormat: &properties,
	}

	return &lbRule, nil
}
开发者ID:hashicorp,项目名称:terraform,代码行数:53,代码来源:resource_arm_loadbalancer_rule.go


示例10: expandRedisConfiguration

func expandRedisConfiguration(d *schema.ResourceData) *map[string]*string {
	configuration := d.Get("redis_configuration").([]interface{})

	output := make(map[string]*string)

	if configuration == nil {
		return &output
	}

	// TODO: can we use this to remove the below? \/
	//config := configuration[0].(map[string]interface{})

	for _, v := range configuration {
		config := v.(map[string]interface{})

		maxClients := config["maxclients"].(string)
		if maxClients != "" {
			output["maxclients"] = azure.String(maxClients)
		}

		maxMemoryDelta := config["maxmemory_delta"].(string)
		if maxMemoryDelta != "" {
			output["maxmemory-delta"] = azure.String(maxMemoryDelta)
		}

		maxMemoryReserved := config["maxmemory_reserved"].(string)
		if maxMemoryReserved != "" {
			output["maxmemory-reserved"] = azure.String(maxMemoryReserved)
		}

		maxMemoryPolicy := config["maxmemory_policy"].(string)
		if maxMemoryPolicy != "" {
			output["maxmemory-policy"] = azure.String(maxMemoryPolicy)
		}
	}

	return &output
}
开发者ID:hashicorp,项目名称:terraform,代码行数:38,代码来源:resource_arm_redis_cache.go


示例11: expandAzureRmLoadBalancerProbe

func expandAzureRmLoadBalancerProbe(d *schema.ResourceData, lb *network.LoadBalancer) (*network.Probe, error) {

	properties := network.ProbePropertiesFormat{
		NumberOfProbes:    azure.Int32(int32(d.Get("number_of_probes").(int))),
		IntervalInSeconds: azure.Int32(int32(d.Get("interval_in_seconds").(int))),
		Port:              azure.Int32(int32(d.Get("port").(int))),
	}

	if v, ok := d.GetOk("protocol"); ok {
		properties.Protocol = network.ProbeProtocol(v.(string))
	}

	if v, ok := d.GetOk("request_path"); ok {
		properties.RequestPath = azure.String(v.(string))
	}

	probe := network.Probe{
		Name:       azure.String(d.Get("name").(string)),
		Properties: &properties,
	}

	return &probe, nil
}
开发者ID:paultyng,项目名称:terraform,代码行数:23,代码来源:resource_arm_loadbalancer_probe.go


示例12: expandAzureRmVirtualMachineDiagnosticsProfile

func expandAzureRmVirtualMachineDiagnosticsProfile(d *schema.ResourceData) *compute.DiagnosticsProfile {
	bootDiagnostics := d.Get("boot_diagnostics").([]interface{})

	diagnosticsProfile := &compute.DiagnosticsProfile{}
	if len(bootDiagnostics) > 0 {
		bootDiagnostic := bootDiagnostics[0].(map[string]interface{})

		diagnostic := &compute.BootDiagnostics{
			Enabled:    riviera.Bool(bootDiagnostic["enabled"].(bool)),
			StorageURI: riviera.String(bootDiagnostic["storage_uri"].(string)),
		}

		diagnosticsProfile.BootDiagnostics = diagnostic

		return diagnosticsProfile
	}

	return nil
}
开发者ID:paultyng,项目名称:terraform,代码行数:19,代码来源:resource_arm_virtual_machine.go


示例13: TestAccCreateDnsZone

func TestAccCreateDnsZone(t *testing.T) {
	rgName := test.RandPrefixString("testrg_", 20)
	zoneName := test.RandString(10) + ".com"

	test.Test(t, test.TestCase{
		Steps: []test.Step{
			&test.StepRegisterResourceProvider{
				Namespace: "Microsoft.Network",
			},
			&test.StepCreateResourceGroup{
				Name:     rgName,
				Location: azure.WestUS,
			},
			&test.StepRunCommand{
				StateBagKey: "dnszone",
				RunCommand: &CreateDNSZone{
					Name:              zoneName,
					ResourceGroupName: rgName,
					Location:          azure.Global,
					Tags: map[string]*string{
						"Purpose": azure.String("Acceptance Testing"),
					},
				},
				StateCommand: &GetDNSZone{
					Name:              zoneName,
					ResourceGroupName: rgName,
				},
				CleanupCommand: &DeleteDNSZone{
					Name:              zoneName,
					ResourceGroupName: rgName,
				},
			},
			&test.StepAssert{
				StateBagKey: "dnszone",
				Assertions: seq.Map{
					"Name":               zoneName,
					"NumberOfRecordSets": 2,
				},
			},
		},
	})
}
开发者ID:jen20,项目名称:riviera,代码行数:42,代码来源:dns_acceptance_test.go


示例14: TestAccUpdateResourceGroup

func TestAccUpdateResourceGroup(t *testing.T) {
	rgName := RandPrefixString("testrg_", 20)

	Test(t, TestCase{
		Steps: []Step{
			&StepCreateResourceGroup{
				Name:     rgName,
				Location: azure.WestUS,
			},
			&StepAssert{
				StateBagKey: "resourcegroup",
				Assertions: seq.Map{
					"Name":     rgName,
					"Location": azure.WestUS,
				},
			},
			&StepRunCommand{
				StateBagKey: "resourcegroup",
				RunCommand: &azure.UpdateResourceGroup{
					Name: rgName,
					Tags: map[string]*string{
						"Purpose": azure.String("Acceptance Testing"),
					},
				},
				StateCommand: &azure.GetResourceGroup{
					Name: rgName,
				},
			},
			&StepAssert{
				StateBagKey: "resourcegroup",
				Assertions: seq.Map{
					"Name":         rgName,
					"Tags.Purpose": "Acceptance Testing",
				},
			},
		},
	})
}
开发者ID:jen20,项目名称:riviera,代码行数:38,代码来源:resource_group_acceptance_test.go


示例15: TestAccCreateDnsARecordSet

func TestAccCreateDnsARecordSet(t *testing.T) {
	rgName := test.RandPrefixString("testrg_", 20)
	zoneName := test.RandString(10) + ".com"
	recordSetName := test.RandPrefixString("rs_", 10)

	test.Test(t, test.TestCase{
		Steps: []test.Step{
			&test.StepRegisterResourceProvider{
				Namespace: "Microsoft.Network",
			},
			&test.StepCreateResourceGroup{
				Name:     rgName,
				Location: azure.WestUS,
			},
			&test.StepRunCommand{
				StateBagKey: "dnszone",
				RunCommand: &CreateDNSZone{
					Name:              zoneName,
					ResourceGroupName: rgName,
					Location:          azure.Global,
					Tags: map[string]*string{
						"Purpose": azure.String("Acceptance Testing"),
					},
				},
				StateCommand: &GetDNSZone{
					Name:              zoneName,
					ResourceGroupName: rgName,
				},
				CleanupCommand: &DeleteDNSZone{
					Name:              zoneName,
					ResourceGroupName: rgName,
				},
			},
			&test.StepRunCommand{
				StateBagKey: "dnsrecordset",
				RunCommand: &CreateARecordSet{
					Name:              recordSetName,
					ZoneName:          zoneName,
					ResourceGroupName: rgName,
					Location:          azure.Global,
					Tags: map[string]*string{
						"Purpose": azure.String("Acceptance Testing"),
					},
					TTL: 300,
					ARecords: []ARecord{
						ARecord{
							IPv4Address: "10.0.10.1",
						},
						ARecord{
							IPv4Address: "10.0.10.2",
						},
					},
				},
				StateCommandURIKey: "ID",
				StateCommand:       &GetARecordSet{},
				CleanupCommand: &DeleteRecordSet{
					Name:              recordSetName,
					ZoneName:          zoneName,
					ResourceGroupName: rgName,
					RecordSetType:     "A",
				},
			},
			&test.StepAssert{
				StateBagKey: "dnsrecordset",
				Assertions: seq.Map{
					"TTL":                     300,
					"Name":                    recordSetName,
					"Location":                azure.Global,
					"ARecords[0].ipv4Address": "10.0.10.1",
					"ARecords[1].ipv4Address": "10.0.10.2",
				},
			},
		},
	})
}
开发者ID:jen20,项目名称:riviera,代码行数:75,代码来源:dns_acceptance_test.go


示例16: expandAzureRmLoadBalancerBackendAddressPools

func expandAzureRmLoadBalancerBackendAddressPools(d *schema.ResourceData) network.BackendAddressPool {
	return network.BackendAddressPool{
		Name: azure.String(d.Get("name").(string)),
	}
}
开发者ID:paultyng,项目名称:terraform,代码行数:5,代码来源:resource_arm_loadbalancer_backend_address_pool.go


示例17: resourceArmSqlDatabaseCreate

func resourceArmSqlDatabaseCreate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*ArmClient)
	rivieraClient := client.rivieraClient

	tags := d.Get("tags").(map[string]interface{})
	expandedTags := expandTags(tags)

	command := &sql.CreateOrUpdateDatabase{
		Name:              d.Get("name").(string),
		Location:          d.Get("location").(string),
		ResourceGroupName: d.Get("resource_group_name").(string),
		ServerName:        d.Get("server_name").(string),
		Tags:              *expandedTags,
		CreateMode:        azure.String(d.Get("create_mode").(string)),
	}

	if v, ok := d.GetOk("source_database_id"); ok {
		command.SourceDatabaseID = azure.String(v.(string))
	}

	if v, ok := d.GetOk("edition"); ok {
		command.Edition = azure.String(v.(string))
	}

	if v, ok := d.GetOk("collation"); ok {
		command.Collation = azure.String(v.(string))
	}

	if v, ok := d.GetOk("max_size_bytes"); ok {
		command.MaxSizeBytes = azure.String(v.(string))
	}

	if v, ok := d.GetOk("source_database_deletion_date"); ok {
		command.SourceDatabaseDeletionDate = azure.String(v.(string))
	}

	if v, ok := d.GetOk("requested_service_objective_id"); ok {
		command.RequestedServiceObjectiveID = azure.String(v.(string))
	}

	if v, ok := d.GetOk("requested_service_objective_name"); ok {
		command.RequestedServiceObjectiveName = azure.String(v.(string))
	}

	createRequest := rivieraClient.NewRequest()
	createRequest.Command = command

	createResponse, err := createRequest.Execute()
	if err != nil {
		return fmt.Errorf("Error creating SQL Database: %s", err)
	}
	if !createResponse.IsSuccessful() {
		return fmt.Errorf("Error creating SQL Database: %s", createResponse.Error)
	}

	readRequest := rivieraClient.NewRequest()
	readRequest.Command = &sql.GetDatabase{
		Name:              d.Get("name").(string),
		ResourceGroupName: d.Get("resource_group_name").(string),
		ServerName:        d.Get("server_name").(string),
	}

	readResponse, err := readRequest.Execute()
	if err != nil {
		return fmt.Errorf("Error reading SQL Database: %s", err)
	}
	if !readResponse.IsSuccessful() {
		return fmt.Errorf("Error reading SQL Database: %s", readResponse.Error)
	}

	resp := readResponse.Parsed.(*sql.GetDatabaseResponse)
	d.SetId(*resp.ID)

	return resourceArmSqlDatabaseRead(d, meta)
}
开发者ID:paultyng,项目名称:terraform,代码行数:75,代码来源:resource_arm_sql_database.go



注:本文中的github.com/jen20/riviera/azure.String函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang azure.Client类代码示例发布时间:2022-05-23
下一篇:
Golang azure.Int32函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap