// PublishIngressNetworkChanges publishes changes to the required
// ingress addresses to the model hosting the offer in the relation.
485510
func (api *CrossModelRelationsAPI) PublishIngressNetworkChanges(
	changes params.IngressNetworksChanges,
) (params.ErrorResults, error) {
	results := params.ErrorResults{
		Results: make([]params.ErrorResult, len(changes.Changes)),
	}
	for i, change := range changes.Changes {
		relationTag, err := api.st.GetRemoteEntity(change.RelationToken)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		logger.Debugf("relation tag for token %+v is %v", change.RelationToken, relationTag)

		if err := api.checkMacaroonsForRelation(relationTag, change.Macaroons); err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		if err := commoncrossmodel.PublishIngressNetworkChange(api.st, relationTag, change); err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
	}
	return results, nil
}
2931
func (c *rackspaceFirewaller) IngressRules(ctx context.ProviderCallContext) ([]network.IngressRule, error) {
	return nil, errors.NotSupportedf("Ports")
}
386576
func sendPingWithChanges(node *Node, target string, changes []Change, timeout time.Duration) (*ping, error) {
	req := ping{
		Checksum:          node.memberlist.Checksum(),
		Changes:           changes,
		Source:            node.Address(),
		SourceIncarnation: node.Incarnation(),
		App:               node.app,
	}

	node.EmitEvent(PingSendEvent{
		Local:   node.Address(),
		Remote:  target,
		Changes: req.Changes,
	})

	logging.Logger("ping").WithFields(log.Fields{
		"local":   node.Address(),
		"remote":  target,
		"changes": req.Changes,
	}).Debug("ping send")

	ctx, cancel := shared.NewTChannelContext(timeout)
	defer cancel()

	peer := node.channel.Peers().GetOrAdd(target)
	startTime := time.Now()

	// send the ping
	errC := make(chan error, 1)
	res := &ping{}
	go func() {
		errC <- json.CallPeer(ctx, peer, node.service, "/protocol/ping", req, res)
	}()

	// get result or timeout
	var err error
	select {
	case err = <-errC:
	case <-ctx.Done():
		err = errors.New("ping timed out")
	}

	if err != nil {
		// ping failed
		logging.Logger("ping").WithFields(log.Fields{
			"local":  node.Address(),
			"remote": target,
			"error":  err,
		}).Debug("ping failed")

		return nil, err
	}

	node.EmitEvent(PingSendCompleteEvent{
		Local:    node.Address(),
		Remote:   target,
		Changes:  req.Changes,
		Duration: time.Now().Sub(startTime),
	})

	return res, err
}
843399
func (w *Wallet) NewChangeAddress(account uint32,
	scope waddrmgr.KeyScope) (btcutil.Address, error) {

	chainClient, err := w.requireChainClient()
	if err != nil {
		return nil, err
	}

	var addr btcutil.Address
	err = walletdb.Update(w.db, func(tx walletdb.ReadWriteTx) error {
		addrmgrNs := tx.ReadWriteBucket(waddrmgrNamespaceKey)
		var err error
		addr, err = w.newChangeAddress(addrmgrNs, account)
		return err
	})
	if err != nil {
		return nil, err
	}

	// Notify the rpc server about the newly created address.
	err = chainClient.NotifyReceived([]btcutil.Address{addr})
	if err != nil {
		return nil, err
	}

	return addr, nil
}
589771
func ParseIngress(ingress *types.Ingress, host net.IP) (ServiceID, *Service, error) {
	svcID := ParseIngressID(ingress)

	if !supportV1beta1(ingress) {
		return svcID, nil, fmt.Errorf("only Single Service Ingress is supported for now, ignoring Ingress")
	}

	ingressPort := ingress.Spec.Backend.ServicePort.IntValue()
	if ingressPort == 0 {
		return svcID, nil, fmt.Errorf("invalid port number")
	}

	svc := NewService(host, false, nil, nil)
	portName := loadbalancer.FEPortName(ingress.Spec.Backend.ServiceName + "/" + ingress.Spec.Backend.ServicePort.String())
	svc.Ports[portName] = loadbalancer.NewFEPort(loadbalancer.TCP, uint16(ingressPort))

	return svcID, svc, nil
}
449081
func (p *Publisher) PublishWithRoutingKey(pub amqp.Publishing, key string) error {
	reqRepl := publishMaybeErr{
		pub: make(chan amqp.Publishing, 2),
		err: make(chan error, 2),
		key: key,
	}

	reqRepl.pub <- pub

	select {
	case <-p.stop:
		// received stop signal
		return ErrPublisherDead
	case p.pubChan <- reqRepl:
	}

	err := <-reqRepl.err
	return err
}
394669
func newIngressRoutes(c *TraefikV1alpha1Client, namespace string) *ingressRoutes {
	return &ingressRoutes{
		client: c.RESTClient(),
		ns:     namespace,
	}
}
948554
func (s *NetworkOfferingService) NewUpdateNetworkOfferingParams() *UpdateNetworkOfferingParams {
	p := &UpdateNetworkOfferingParams{}
	p.p = make(map[string]interface{})
	return p
}
112395
func (api *CrossModelRelationsAPI) PublishRelationChanges(
	changes params.RemoteRelationsChanges,
) (params.ErrorResults, error) {
	results := params.ErrorResults{
		Results: make([]params.ErrorResult, len(changes.Changes)),
	}
	for i, change := range changes.Changes {
		relationTag, err := api.st.GetRemoteEntity(change.RelationToken)
		if err != nil {
			if errors.IsNotFound(err) {
				logger.Debugf("no relation tag %+v in model %v, exit early", change.RelationToken, api.st.ModelUUID())
				continue
			}
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		logger.Debugf("relation tag for token %+v is %v", change.RelationToken, relationTag)
		if err := api.checkMacaroonsForRelation(relationTag, change.Macaroons); err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		if err := commoncrossmodel.PublishRelationChange(api.st, relationTag, change); err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		if change.Life != params.Alive {
			delete(api.relationToOffer, relationTag.Id())
		}
	}
	return results, nil
}
445658
func (c *Client) ChangeResourceRecordSets(hostedZoneID string, input ChangeResourceRecordSetsRequest) (*ChangeResourceRecordSetsResponse, error) {
	requestURL := fmt.Sprintf("%s/%s/hostedzone/%s/rrset", c.BaseURL, apiVersion, hostedZoneID)

	body := &bytes.Buffer{}
	body.Write([]byte(xml.Header))
	err := xml.NewEncoder(body).Encode(input)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest(http.MethodPost, requestURL, body)
	if err != nil {
		return nil, err
	}

	req.Header.Set("Content-Type", "text/xml; charset=utf-8")

	err = c.sign(req)
	if err != nil {
		return nil, fmt.Errorf("an error occurred during the creation of the signature: %v", err)
	}

	res, err := c.HTTPClient.Do(req)
	if err != nil {
		return nil, err
	}
	if res.Body == nil {
		return nil, errors.New("the response body is nil")
	}

	defer res.Body.Close()

	if res.StatusCode != http.StatusOK {
		errResp := &ErrorResponse{}
		err = xml.NewDecoder(res.Body).Decode(errResp)
		if err != nil {
			return nil, fmt.Errorf("an error occurred while unmarshaling the error body to XML: %v", err)
		}

		return nil, fmt.Errorf("an error occurred: %s", errResp.Error.Message)
	}

	output := &ChangeResourceRecordSetsResponse{}
	err = xml.NewDecoder(res.Body).Decode(output)
	if err != nil {
		return nil, fmt.Errorf("an error occurred while unmarshaling the response body to XML: %v", err)
	}

	return output, err
}
235998
func (c *ingresses) Update(ingress *extensions.Ingress) (result *extensions.Ingress, err error) {
	result = &extensions.Ingress{}
	err = c.client.Put().
		Namespace(c.ns).
		Resource("ingresses").
		Name(ingress.Name).
		Body(ingress).
		Do().
		Into(result)
	return
}
1118210
func Convert_networking_IngressSpec_To_v1beta1_IngressSpec(in *networking.IngressSpec, out *v1beta1.IngressSpec, s conversion.Scope) error {
	return autoConvert_networking_IngressSpec_To_v1beta1_IngressSpec(in, out, s)
}
79719
func (t *Transport) NewSingleOutbound(addr string) *Outbound {
	chooser := peerchooser.NewSingle(hostport.PeerIdentifier(addr), t)
	return t.NewOutbound(chooser)
}
338066
func (s *ServiceCache) DeleteIngress(ingress *types.Ingress) {
	svcID := ParseIngressID(ingress)

	s.mutex.Lock()
	oldService, ok := s.ingresses[svcID]
	endpoints, _ := s.endpoints[svcID]
	delete(s.ingresses, svcID)
	s.mutex.Unlock()

	if ok {
		s.Events <- ServiceEvent{
			Action:    DeleteIngress,
			ID:        svcID,
			Service:   oldService,
			Endpoints: endpoints,
		}
	}
}
1141044
func Convert_v1beta1_Ingress_To_networking_Ingress(in *v1beta1.Ingress, out *networking.Ingress, s conversion.Scope) error {
	return autoConvert_v1beta1_Ingress_To_networking_Ingress(in, out, s)
}
341504
func Convert_v1beta1_IngressBackend_To_networking_IngressBackend(in *v1beta1.IngressBackend, out *networking.IngressBackend, s conversion.Scope) error {
	return autoConvert_v1beta1_IngressBackend_To_networking_IngressBackend(in, out, s)
}
1185165
func (c *neutronFirewaller) IngressRules(ctx context.ProviderCallContext) ([]network.IngressRule, error) {
	rules, err := c.ingressRules(ctx, c.ingressRulesInGroup)
	if err != nil {
		common.HandleCredentialError(IsAuthorisationFailure, err, ctx)
		return rules, errors.Trace(err)
	}
	return rules, nil
}