百度智能云

All Product Document

          Relational Database Service

          White List Management

          White List Management

          View Whitelist

          Use the following codes to get the white list under an instance.

          // import "github.com/baidubce/bce-sdk-go/services/rds"
          result, err := client.GetSecurityIps(instanceId)
          if err != nil {
              fmt.Printf("get securityIp list error: %+v\n", err)
              return
          }
          data, _ := json.Marshal(result)
          fmt.Println(string(data))
          fmt.Println(result.Etag)
          fmt.Printf("get securityIp list success\n")

          Note: When updating the white list, get the latest Etag through this interface.

          Update Whitelist

          Use the following codes to update the white list under an instance.

          // import "github.com/baidubce/bce-sdk-go/services/rds"
          
          result, err := client.GetSecurityIps(instanceId)
          if err != nil {
              fmt.Printf("get securityIp list error: %+v\n", err)
              return
          }
          fmt.Println(result.Etag)
          fmt.Printf("get securityIp list success\n")
          
          args := &rds.UpdateSecurityIpsArgs{
          				SecurityIps:  []string{
          					"%",
          					"192.0.0.1",
          					"192.0.0.2",
          				},
          			}
          er := client.UpdateSecurityIps(instanceId, result.Etag, args)
          if er != nil {
              fmt.Printf("update securityIp list error: %+v\n", er)
              return
          }
          fmt.Printf("update securityIp list success\n")

          Note: When updating the white list, get the latest Etag through viewing the white list. The white list should be fully updated, and all the white lists should be added every update.

          Previous
          Parameter Management
          Next
          Exceptions Handling