// SetOrganizationInformation sets the currently targeted organization.
493556
func (config *Config) SetOrganizationInformation(guid string, name string) {
	config.ConfigFile.TargetedOrganization.GUID = guid
	config.ConfigFile.TargetedOrganization.Name = name
	config.ConfigFile.TargetedOrganization.QuotaDefinition = QuotaDefinition{}
}
1140988
func (s *ASN1Subject) SetOrganizationalUnit(v string) *ASN1Subject {
	s.OrganizationalUnit = &v
	return s
}
1308909
func (s *DomainJoinInfo) SetOrganizationalUnitDistinguishedName(v string) *DomainJoinInfo {
	s.OrganizationalUnitDistinguishedName = &v
	return s
}
411783
func (s *Service) CreateOrganization(ctx context.Context, o *platform.Organization) error {
	op := OpPrefix + platform.OpCreateOrganization
	if o.Name = strings.TrimSpace(o.Name); o.Name == "" {
		return platform.ErrOrgNameisEmpty
	}
	if _, err := s.FindOrganization(ctx, platform.OrganizationFilter{Name: &o.Name}); err == nil {
		return &platform.Error{
			Code: platform.EConflict,
			Op:   op,
			Msg:  fmt.Sprintf("organization with name %s already exists", o.Name),
		}
	}
	o.ID = s.IDGenerator.ID()
	err := s.PutOrganization(ctx, o)
	if err != nil {
		return &platform.Error{
			Op:  op,
			Err: err,
		}
	}
	return nil
}
491331
func (s *Service) UpdateOrganization(ctx context.Context, id influxdb.ID, upd influxdb.OrganizationUpdate) (*influxdb.Organization, error) {
	var o *influxdb.Organization
	err := s.kv.Update(ctx, func(tx Tx) error {
		org, pe := s.updateOrganization(ctx, tx, id, upd)
		if pe != nil {
			return &influxdb.Error{
				Err: pe,
			}
		}
		o = org
		return nil
	})

	return o, err
}
1001036
func (s *OrganizationService) CreateOrganization(ctx context.Context, o *platform.Organization) error {
	if o.Name == "" {
		return kerrors.InvalidDataf("organization name is required")
	}

	url, err := newURL(s.Addr, organizationPath)
	if err != nil {
		return err
	}

	octets, err := json.Marshal(o)
	if err != nil {
		return err
	}

	req, err := http.NewRequest("POST", url.String(), bytes.NewReader(octets))
	if err != nil {
		return err
	}

	req.Header.Set("Content-Type", "application/json")
	SetToken(s.Token, req)

	hc := newClient(url.Scheme, s.InsecureSkipVerify)

	resp, err := hc.Do(req)
	if err != nil {
		return err
	}

	// TODO(jsternberg): Should this check for a 201 explicitly?
	if err := CheckError(resp, true); err != nil {
		return err
	}

	if err := json.NewDecoder(resp.Body).Decode(o); err != nil {
		return err
	}

	return nil
}
677641
func (s *DescribeNotificationSubscriptionsInput) SetOrganizationId(v string) *DescribeNotificationSubscriptionsInput {
	s.OrganizationId = &v
	return s
}
71986
func (s *DescribeGroupsInput) SetOrganizationId(v string) *DescribeGroupsInput {
	s.OrganizationId = &v
	return s
}
415551
func (actor Actor) SetOrganizationDefaultIsolationSegment(orgGUID string, isoSegGUID string) (Warnings, error) {
	_, apiWarnings, err := actor.CloudControllerClient.UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID, isoSegGUID)
	return Warnings(apiWarnings), err
}
337881
func (s *Service) UpdateOrganization(w http.ResponseWriter, r *http.Request) {
	var req organizationRequest
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		invalidJSON(w, s.Logger)
		return
	}

	if err := req.ValidUpdate(); err != nil {
		invalidData(w, err, s.Logger)
		return
	}

	ctx := r.Context()
	id := httprouter.GetParamFromContext(ctx, "oid")

	org, err := s.Store.Organizations(ctx).Get(ctx, chronograf.OrganizationQuery{ID: &id})
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	if req.Name != "" {
		org.Name = req.Name
	}

	if req.DefaultRole != "" {
		org.DefaultRole = req.DefaultRole
	}

	err = s.Store.Organizations(ctx).Update(ctx, org)
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	res := newOrganizationResponse(org)
	location(w, res.Links.Self)
	encodeJSON(w, http.StatusOK, res, s.Logger)

}
379897
func (s *ListResourcesInput) SetOrganizationId(v string) *ListResourcesInput {
	s.OrganizationId = &v
	return s
}
759303
func (s *CreateComputerInput) SetOrganizationalUnitDistinguishedName(v string) *CreateComputerInput {
	s.OrganizationalUnitDistinguishedName = &v
	return s
}
738915
func (s *ListUsersInput) SetOrganizationId(v string) *ListUsersInput {
	s.OrganizationId = &v
	return s
}
646364
func (s *JoinDomainInput) SetOrganizationalUnit(v string) *JoinDomainInput {
	s.OrganizationalUnit = &v
	return s
}
1056329
func (s *CreateGroupInput) SetOrganizationId(v string) *CreateGroupInput {
	s.OrganizationId = &v
	return s
}
414567
func (api OrganizationsAPI) SetOrganizationLogo(w http.ResponseWriter, r *http.Request) {
	globalid := mux.Vars(r)["globalid"]

	body := struct {
		Logo string
	}{}

	if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
		log.Error("Error while saving logo: ", err.Error())
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	logoMgr := organization.NewLogoManager(r)

	// server side file size validation check. Normally uploaded files should never get this large due to size constraints, but check anyway
	if len(body.Logo) > 1024*1024*5 {
		log.Error("Error while saving file: file too large")
		http.Error(w, http.StatusText(http.StatusRequestEntityTooLarge), http.StatusRequestEntityTooLarge)
		return
	}
	_, err := logoMgr.SaveLogo(globalid, body.Logo)
	if err != nil {
		log.Error("Error while saving logo: ", err.Error())
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	w.WriteHeader(http.StatusOK)
}
390114
func (s *ResetPasswordInput) SetOrganizationId(v string) *ResetPasswordInput {
	s.OrganizationId = &v
	return s
}