package migrationAPI import ( "errors" "fmt" "net/http" "net/url" ) // CollectFromBigQuery runs the /collect/from_bigquery/:collection/:dc method func (c *Client) CollectFromBigQuery(collection, datacenter string, options ...*Options) (*AuditResponse, error) { opts := processOptions(options...) if opts.Account == nil && opts.Device == nil { return nil, errors.New("must set one option value: Account or Device") } uri := fmt.Sprintf("/collect/from_bigquery/%s/%s", url.PathEscape(collection), url.PathEscape(datacenter)) req, err := c.newRequest(c.URL+uri, http.MethodPost, nil, opts) if err != nil { return nil, err } resp := new(AuditResponse) return resp, c.do(req, resp, opts) } // CollectFromDCX runs the /collect/from_dcx/:collection method func (c *Client) CollectFromDCX(collection string, options ...*Options) (*CollectResponse, error) { return c.collectGeneric( fmt.Sprintf("/collect/from_dcx/%s", url.PathEscape(collection)), options..., ) } // CollectFromLinkedCMDB runs the /collect/from_linked_cmdb/:collection method func (c *Client) CollectFromLinkedCMDB(collection string, options ...*Options) (*CollectResponse, error) { return c.collectGeneric( fmt.Sprintf("/collect/from_linked_cmdb/%s", url.PathEscape(collection)), options..., ) } // CollectFromRVI runs the /collect/from_rvi/:collection method func (c *Client) CollectFromRVI(collection string, options ...*Options) (*CollectResponse, error) { return c.collectGeneric( fmt.Sprintf("/collect/from_rvi/%s", url.PathEscape(collection)), options..., ) } // CollectFromUnipede runs the /collect/from_unipede/:collection method func (c *Client) CollectFromUnipede(collection string, options ...*Options) (*CollectResponse, error) { return c.collectGeneric( fmt.Sprintf("/collect/from_unipede/%s", url.PathEscape(collection)), options..., ) } // CollectTranslations runs the /collect/translations/:collection method func (c *Client) CollectTranslations(collection string, options ...*Options) (*CollectResponse, error) { return c.collectGeneric( fmt.Sprintf("/collect/translations/%s", url.PathEscape(collection)), options..., ) } func (c *Client) collectGeneric(uri string, options ...*Options) (*CollectResponse, error) { opts := processOptions(options...) if opts.MoveGroup == nil && opts.Account == nil && opts.Device == nil { return nil, errors.New("must set one option value: MoveGroup or Account or Device") } req, err := c.newRequest(c.URL+uri, http.MethodPost, nil, opts) if err != nil { return nil, err } resp := new(CollectResponse) return resp, c.do(req, resp, opts) }