// ensure that when update events are emitted, we unwrap resourceEntry
776077
func (r resourceEntry) EventUpdate(oldObject api.StoreObject) api.Event {
	if oldObject != nil {
		return api.EventUpdateResource{Resource: r.Resource, OldResource: oldObject.(resourceEntry).Resource}
	}
	return api.EventUpdateResource{Resource: r.Resource}
}
1105207
func updateResource(res charmresource.Resource, fp charmresource.Fingerprint, size int64) (charmresource.Resource, error) {
	res.Origin = charmresource.OriginUpload
	res.Revision = 0
	res.Fingerprint = fp
	res.Size = size

	if err := res.Validate(); err != nil {
		return res, errors.Trace(err)
	}
	return res, nil
}
1031083
func (p ResourcePersistence) RemovePendingAppResources(applicationID string, pendingIDs map[string]string) error {
	buildTxn := func(int) ([]txn.Op, error) {
		return p.NewRemovePendingAppResourcesOps(applicationID, pendingIDs)
	}
	return errors.Trace(p.base.Run(buildTxn))
}
732837
func (registry *Registry) RunEventQueue(resourceName ResourceName) *oscache.EventQueue {
	var client cache.Getter
	var expectedType interface{}

	switch resourceName {
	case HostSubnets:
		expectedType = &osapi.HostSubnet{}
		client = registry.oClient
	case NetNamespaces:
		expectedType = &osapi.NetNamespace{}
		client = registry.oClient
	case Nodes:
		expectedType = &kapi.Node{}
		client = registry.kClient
	case Namespaces:
		expectedType = &kapi.Namespace{}
		client = registry.kClient
	case Services:
		expectedType = &kapi.Service{}
		client = registry.kClient
	case Pods:
		expectedType = &kapi.Pod{}
		client = registry.kClient
	default:
		log.Fatalf("Unknown resource %s during initialization of event queue", resourceName)
	}

	lw := cache.NewListWatchFromClient(client, strings.ToLower(string(resourceName)), kapi.NamespaceAll, fields.Everything())
	eventQueue := oscache.NewEventQueue(cache.MetaNamespaceKeyFunc)
	// Repopulate event queue every 30 mins
	// Existing items in the event queue will have watch.Modified event type
	cache.NewReflector(lw, expectedType, eventQueue, 30*time.Minute).Run()
	return eventQueue
}
1086841
func (mc MongoClient) UpdateEvent(e contract.Event) error {
	var mapped models.Event
	id, err := mapped.FromContract(e, mc)
	if err != nil {
		return err
	}

	mapped.TimestampForUpdate()

	return mc.updateId(db.EventsCollection, id, mapped)
}
716700
func (client ResourcesClient) CreateOrUpdateByID(ctx context.Context, resourceID string, parameters resources.GenericResource, apiVersion string) (result resources.CreateOrUpdateByIDFuture, err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdateByID")
		defer func() {
			sc := -1
			if result.Response() != nil {
				sc = result.Response().StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	if err := validation.Validate([]validation.Validation{
		{TargetValue: parameters,
			Constraints: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Null, Rule: false,
				Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil {
		return result, validation.NewError("resources.Client", "CreateOrUpdateByID", err.Error())
	}

	req, err := client.CreateOrUpdateByIDPreparer(ctx, resourceID, parameters)
	if err != nil {
		err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdateByID", nil, "Failure preparing request")
		return
	}
	setAPIVersion(req, apiVersion)

	result, err = client.CreateOrUpdateByIDSender(req)
	if err != nil {
		err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdateByID", result.Response(), "Failure sending request")
		return
	}

	return
}
431359
func (r *remoteServiceObserver) OnUpdate(key store.Key) {
	if svc, ok := key.(*service.ClusterService); ok {
		scopedLog := log.WithFields(logrus.Fields{logfields.ServiceName: svc.String()})
		scopedLog.Debugf("Update event of remote service %#v", svc)

		mesh := r.remoteCluster.mesh
		mesh.globalServices.onUpdate(svc)

		if merger := mesh.conf.ServiceMerger; merger != nil {
			merger.MergeExternalServiceUpdate(svc)
		} else {
			scopedLog.Debugf("Ignoring remote service update. Missing merger function")
		}
	} else {
		log.Warningf("Received unexpected remote service update object %+v", key)
	}
}
868818
func (c *FakeEvents) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
	action := core.NewRootUpdateAction(eventsResource, event)
	if c.ns != "" {
		action = core.NewUpdateAction(eventsResource, c.ns, event)
	}
	obj, err := c.Fake.Invokes(action, event)
	if obj == nil {
		return nil, err
	}

	return obj.(*v1.Event), err
}
940564
func resourceClosed() error {
	if !resourceDebugEnabled {
		return errors.New("resource closed")
	}

	var buf [4096]byte
	return fmt.Errorf("resource closed:\n%s", buf[:runtime.Stack(buf[:], false)])
}
867116
func resourceAwsLambdaEventSourceMappingDelete(d *schema.ResourceData, meta interface{}) error {
	conn := meta.(*AWSClient).lambdaconn

	log.Printf("[INFO] Deleting Lambda event source mapping: %s", d.Id())

	params := &lambda.DeleteEventSourceMappingInput{
		UUID: aws.String(d.Id()),
	}

	err := resource.Retry(5*time.Minute, func() *resource.RetryError {
		_, err := conn.DeleteEventSourceMapping(params)
		if err != nil {
			if isAWSErr(err, lambda.ErrCodeResourceInUseException, "") {
				return resource.RetryableError(err)
			}
			return resource.NonRetryableError(err)
		}
		return nil
	})

	if err != nil {
		return fmt.Errorf("Error deleting Lambda event source mapping: %s", err)
	}

	return nil
}
1169219
func (m *MockLambdaAPI) UpdateEventSourceMapping(arg0 *lambda.UpdateEventSourceMappingInput) (*lambda.EventSourceMappingConfiguration, error) {
	ret := m.ctrl.Call(m, "UpdateEventSourceMapping", arg0)
	ret0, _ := ret[0].(*lambda.EventSourceMappingConfiguration)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
348814
func (es *EventSource) Close() {
	es.locker.Lock()
	defer es.locker.Unlock()
	if !es.closed {
		es.conn.Close()
		close(es.closeNotify)
		es.closed = true
	}
}
1317103
func (v *ProcTableImpl) RemoveEntry(pvName string) (CleanupState, *time.Time, error) {
	v.mutex.Lock()
	defer v.mutex.Unlock()
	entry, ok := v.procTable[pvName]
	if !ok {
		return CSNotFound, nil, nil
	}
	if entry.Status == CSRunning {
		return CSUnknown, nil, fmt.Errorf("cannot remove proctable entry for %q when it is still running", pvName)
	}
	if entry.Status == CSUnknown {
		return CSUnknown, nil, fmt.Errorf("proctable entry for %q in unexpected unknown state", pvName)
	}
	delete(v.procTable, pvName)
	return entry.Status, &entry.StartTime, nil
}
480695
func (_m *ClientInterface) UpdateResourcePool(p pool.ResourcePool) error {
	ret := _m.Called(p)

	var r0 error
	if rf, ok := ret.Get(0).(func(pool.ResourcePool) error); ok {
		r0 = rf(p)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
982254
func (command S3LambdaEventSourceResource) Update(awsSession *session.Session,
	event *CloudFormationLambdaEvent,
	logger *logrus.Logger) (map[string]interface{}, error) {
	return command.updateNotification(true, awsSession, event, logger)
}
1057866
func (p ResourcePersistence) SetResource(res resource.Resource) error {
	stored, err := p.getStored(res)
	if errors.IsNotFound(err) {
		stored = storedResource{Resource: res}
	} else if err != nil {
		return errors.Trace(err)
	}
	// TODO(ericsnow) Ensure that stored.Resource matches res? If we do
	// so then the following line is unnecessary.
	stored.Resource = res

	if err := res.Validate(); err != nil {
		return errors.Annotate(err, "bad resource")
	}

	buildTxn := func(attempt int) ([]txn.Op, error) {
		// This is an "upsert".
		var ops []txn.Op
		switch attempt {
		case 0:
			ops = newInsertResourceOps(stored)
		case 1:
			ops = newUpdateResourceOps(stored)
		default:
			// Either insert or update will work so we should not get here.
			return nil, errors.New("setting the resource failed")
		}
		if stored.PendingID == "" {
			// Only non-pending resources must have an existing application.
			ops = append(ops, p.base.ApplicationExistsOps(res.ApplicationID)...)
		}
		return ops, nil
	}
	if err := p.base.Run(buildTxn); err != nil {
		return errors.Trace(err)
	}
	return nil
}
723845
func (x *AuditEvent) UnmarshalJSON(data []byte) (err error) {
	x2 := auditEvent{}
	if err = json.Unmarshal(data, &x2); err == nil {
		if x2.Contained != nil {
			for i := range x2.Contained {
				x2.Contained[i] = MapToResource(x2.Contained[i], true)
			}
		}
		*x = AuditEvent(x2)
		return x.checkResourceType()
	}
	return
}