// TODO(ericsnow) Incorporate the application and resource name into the ID
// instead of just using a UUID?
// newPendingID generates a new unique identifier for a resource.
439325
func newPendingID() (string, error) {
	uuid, err := utils.NewUUID()
	if err != nil {
		return "", errors.Annotate(err, "could not create new resource ID")
	}
	return uuid.String(), nil
}
120143
func (dev *LinkLayerDevice) ProviderID() network.Id {
	return network.Id(dev.doc.ProviderID)
}
7461
func WithResourceID(id int64) MarshalOption {
	return func(c *MarshalConfig) error {
		c.ID = id
		return nil
	}
}
1218940
func (d *ResourceData) Id() string {
	var result string

	if d.state != nil {
		result = d.state.ID
		if result == "" {
			result = d.state.Attributes["id"]
		}
	}

	if d.newState != nil {
		result = d.newState.ID
		if result == "" {
			result = d.newState.Attributes["id"]
		}
	}

	return result
}
264739
func (addr *Address) ProviderID() network.Id {
	return network.Id(addr.doc.ProviderID)
}
569498
func NewResourceByStringID(id string) *Resource {
	intID, err := strconv.ParseInt(id, 10, 64)
	if err != nil {
		panic(err)
	}
	return &Resource{ID: intID}
}
173556
func (dm *PendingDeploymentMgr) NewPendingDeployment(deploymentID, templateID, poolID string) (*PendingDeployment, error) {
	dm.mutex.Lock()
	defer dm.mutex.Unlock()
	if _, ok := dm.deployments[deploymentID]; ok {
		return nil, ErrPendingDeploymentConflict
	}
	deployment := NewPendingDeployment(deploymentID, templateID, poolID)
	dm.deployments[deploymentID] = &deployment
	return &deployment, nil
}
327548
func (p ResourcePersistence) getOnePending(resID, pendingID string) (resourceDoc, error) {
	logger.Tracef("querying db for resource %q (pending %q)", resID, pendingID)
	id := pendingResourceID(resID, pendingID)
	var doc resourceDoc
	if err := p.base.One(resourcesC, id, &doc); err != nil {
		return doc, errors.Trace(err)
	}
	return doc, nil
}
824559
func (s *UpdateResourceInput) SetResourceId(v string) *UpdateResourceInput {
	s.ResourceId = &v
	return s
}
1092513
func (s *Configurations) SetPending(v *ConfigurationId) *Configurations {
	s.Pending = v
	return s
}
167327
func (st resourceState) GetPendingResource(applicationID, name, pendingID string) (resource.Resource, error) {
	var res resource.Resource

	resources, err := st.persist.ListPendingResources(applicationID)
	if err != nil {
		// We do not call VerifyApplication() here because pending resources
		// do not have to have an existing application.
		return res, errors.Trace(err)
	}

	for _, res := range resources {
		if res.Name == name && res.PendingID == pendingID {
			return res, nil
		}
	}
	return res, errors.NotFoundf("pending resource %q (%s)", name, pendingID)
}
1246965
func ParseResourceID(resourceID string) (Resource, error) {

	const resourceIDPatternText = `(?i)subscriptions/(.+)/resourceGroups/(.+)/providers/(.+?)/(.+?)/(.+)`
	resourceIDPattern := regexp.MustCompile(resourceIDPatternText)
	match := resourceIDPattern.FindStringSubmatch(resourceID)

	if len(match) == 0 {
		return Resource{}, fmt.Errorf("parsing failed for %s. Invalid resource Id format", resourceID)
	}

	v := strings.Split(match[5], "/")
	resourceName := v[len(v)-1]

	result := Resource{
		SubscriptionID: match[1],
		ResourceGroup:  match[2],
		Provider:       match[3],
		ResourceType:   match[4],
		ResourceName:   resourceName,
	}

	return result, nil
}
1327746
func NewID() string {
	b := make([]byte, 8)
	rand.Read(b)
	return fmt.Sprintf("%x", b)
}
1314963
func (s *UpdateIntegrationResponseInput) SetResourceId(v string) *UpdateIntegrationResponseInput {
	s.ResourceId = &v
	return s
}
549181
func (r *Resource) Id(options ...interface{}) *Resource {
	if len(options) > 0 {
		id := ""
		switch v := options[0].(type) {
		default:
			id = v.(string)
		case int:
			id = strconv.Itoa(v)
		case int64:
			id = strconv.FormatInt(v, 10)
		}
		url := r.Url + "/" + id
		header := r.Headers
		if header == nil {
			header = http.Header{}
		}
		newR := &Resource{id: id, Url: url, Api: r.Api, Headers: header, Response: &r.Response}

		if len(options) > 1 {
			newR.Response = options[1]
		}
		return newR
	}
	return r
}
462656
func (s *DescribeResourceInput) SetResourceId(v string) *DescribeResourceInput {
	s.ResourceId = &v
	return s
}
139230
func (s *ComplianceViolator) SetResourceId(v string) *ComplianceViolator {
	s.ResourceId = &v
	return s
}