// 配置操作接口
// -------------------------------------------------------------------------------
//  DomainConfigs 获取指定加速域名的配置
//  @configList 为空时代表查询所有
//  @link https://help.aliyun.com/document_detail/27169.html?spm=0.0.0.0.fewJpA
191605
func (c *CDN) DomainConfigs(domainName string, resp interface{}, configList ...ConfigName) (err error) {
	config := []string{}
	for _, val := range configList {
		config = append(config, string(val))
	}
	err = c.domainConfigs(domainName, resp, config...)
	return
}
1081616
func (client *Client) GetDomains(ctx context.Context) ([]DNSDomain, error) {
	resp, err := client.dnsRequest(ctx, "/v1/domains", nil, "", "GET")
	if err != nil {
		return nil, err
	}

	var d []DNSDomainResponse
	if err := json.Unmarshal(resp, &d); err != nil {
		return nil, err
	}

	domains := make([]DNSDomain, len(d))
	for i := range d {
		domains[i] = *d[i].Domain
	}
	return domains, nil
}
1269922
func (c *Client) GetDomains() ([]Domain, error) {
	req, err := c.NewRequest(nil, "GET", "/domains")
	if err != nil {
		return nil, err
	}
	resp, err := c.Http.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	domainResponses := []DomainResponse{}
	err = decode(resp.Body, &domainResponses)
	if err != nil {
		return nil, err
	}
	domains := make([]Domain, len(domainResponses))
	for i, dr := range domainResponses {
		domains[i] = dr.Domain
	}
	return domains, nil
}
153221
func (s *GetDomainNameOutput) SetDomainNameConfigurations(v []*DomainNameConfiguration) *GetDomainNameOutput {
	s.DomainNameConfigurations = v
	return s
}
1007376
func (s *DomainService) NewListDomainsParams() *ListDomainsParams {
	p := &ListDomainsParams{}
	p.p = make(map[string]interface{})
	return p
}
943784
func suffixesForRateLimiting(names []string) ([]string, error) {
	var suffixMatches []string
	for _, name := range names {
		_, err := publicsuffix.Domain(name)
		if err != nil {
			// Like `domainsForRateLimiting`, the only possible errors here are:
			// (1) publicsuffix.Domain is giving garbage values
			// (2) the public suffix is the domain itself
			// We assume 2 and collect it into the result
			suffixMatches = append(suffixMatches, name)
		}
	}
	return core.UniqueLowerNames(suffixMatches), nil
}
1181186
func DomainsAdd(appID, domain string) error {
	c, appID, err := load(appID)

	if err != nil {
		return err
	}

	fmt.Printf("Adding %s to %s... ", domain, appID)

	quit := progress()
	_, err = domains.New(c, appID, domain)
	quit <- true
	<-quit

	if err != nil {
		return err
	}

	fmt.Println("done")
	return nil
}
107423
func BindTextdomainCodeset(domainname string, codeset string) string {
	cdomainname := C.CString(domainname)
	defer C.free(unsafe.Pointer(cdomainname))

	ccodeset := C.CString(codeset)
	defer C.free(unsafe.Pointer(ccodeset))

	return C.GoString(C.bind_textdomain_codeset(cdomainname, ccodeset))
}
848776
func Domain(domain string) Option {
	return func(c *Client) error {
		c.domain = domain
		return nil
	}
}
843031
func (c *CDN) SetErrorPageConfig(domainName, customPageUrl string, pageType PageType, resp interface{}) (err error) {
	if global.EmptyString == domainName {
		return errors.New("domainName should not be empty")
	}

	if pageType == OtherPageType && global.EmptyString == customPageUrl {
		return errors.New("'customPageUrl' should not be empty when the value of 'pageType' is 'other'")
	}

	req := c.cdnReq.Clone().(*Request)
	req.Action = SetErrorPageConfigAction
	req.SetArgs("DomainName", domainName)
	req.SetArgs("PageType", string(pageType))
	if global.EmptyString != customPageUrl {
		req.SetArgs("CustomPageUrl", customPageUrl)
	}
	err = c.rpc.Query(req, resp)
	return
}
179643
func DomainPrefix(url string) string {
	domain := Domain(url)
	if len(domain) != 0 {
		return domain[:strings.Index(domain, ".")]
	}
	return ""
}
669809
func Domain(named Named) string {
	if r, ok := named.(namedRepository); ok {
		return r.Domain()
	}
	domain, _ := splitDomain(named.Name())
	return domain
}
960416
func (client *Client) AddDomainGroup(args *AddDomainGroupArgs) (response *AddDomainGroupResponse, err error) {
	action := "AddDomainGroup"
	response = &AddDomainGroupResponse{}
	err = client.Invoke(action, args, response)
	if err == nil {
		return response, nil
	} else {
		log.Printf("%s error, %v", action, err)
		return response, err
	}
}
154436
func (s *DomainService) ListDomains(p *ListDomainsParams) (*ListDomainsResponse, error) {
	resp, err := s.cs.newRequest("listDomains", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ListDomainsResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
3749
func (c *Client) DomainCreate(appIdentity string, hostname string) (*Domain, error) {
	params := struct {
		Hostname string `json:"hostname"`
	}{
		Hostname: hostname,
	}
	var domainRes Domain
	return &domainRes, c.Post(&domainRes, "/apps/"+appIdentity+"/domains", params)
}
911639
func (c *Client) HostedModelConfigs() ([]HostedConfig, error) {
	result := params.HostedModelConfigsResults{}
	err := c.facade.FacadeCall("HostedModelConfigs", nil, &result)
	if err != nil {
		return nil, errors.Trace(err)
	}
	// If we get to here, we have some values. Each value may or
	// may not have an error, but it should at least have a name
	// and owner.
	hostedConfigs := make([]HostedConfig, len(result.Models))
	for i, modelConfig := range result.Models {
		hostedConfigs[i].Name = modelConfig.Name
		tag, err := names.ParseUserTag(modelConfig.OwnerTag)
		if err != nil {
			hostedConfigs[i].Error = errors.Trace(err)
			continue
		}
		hostedConfigs[i].Owner = tag
		if modelConfig.Error != nil {
			hostedConfigs[i].Error = errors.Trace(modelConfig.Error)
			continue
		}
		hostedConfigs[i].Config = modelConfig.Config
		spec, err := c.MakeCloudSpec(modelConfig.CloudSpec)
		if err != nil {
			hostedConfigs[i].Error = errors.Trace(err)
			continue
		}
		hostedConfigs[i].CloudSpec = spec
	}
	return hostedConfigs, err
}
989090
func (u *UniterAPI) ConfigSettings(args params.Entities) (params.ConfigSettingsResults, error) {
	result := params.ConfigSettingsResults{
		Results: make([]params.ConfigSettingsResult, len(args.Entities)),
	}
	canAccess, err := u.accessUnit()
	if err != nil {
		return params.ConfigSettingsResults{}, err
	}
	for i, entity := range args.Entities {
		tag, err := names.ParseUnitTag(entity.Tag)
		if err != nil {
			result.Results[i].Error = common.ServerError(common.ErrPerm)
			continue
		}
		err = common.ErrPerm
		if canAccess(tag) {
			var unit *state.Unit
			unit, err = u.getUnit(tag)
			if err == nil {
				var settings charm.Settings
				settings, err = unit.ConfigSettings()
				if err == nil {
					result.Results[i].Settings = params.ConfigSettings(settings)
				}
			}
		}
		result.Results[i].Error = common.ServerError(err)
	}
	return result, nil
}