|
- /* ******************************************************************************
- * 2019 - present Contributed by Apulis Technology (Shenzhen) Co. LTD
- *
- * This program and the accompanying materials are made available under the
- * terms of the MIT License, which is available at
- * https://www.opensource.org/licenses/MIT
- *
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- * SPDX-License-Identifier: MIT
- ******************************************************************************/
- package services
-
- import (
- "bytes"
- "encoding/json"
- "fmt"
- "net/http"
- "net/url"
- "time"
-
- "github.com/apulis/app/ai-arts-backend/internal/configs"
- "github.com/apulis/app/ai-arts-backend/internal/dto"
- "github.com/apulis/app/ai-arts-backend/internal/utils"
- "github.com/apulis/app/ai-arts-backend/pkg/exports"
- )
-
- var globalJobSchedulerService = &JobSchedulerService{}
-
- func GetGlobalJobSchedulerService() *JobSchedulerService {
- return globalJobSchedulerService
- }
-
- type JobSchedulerService struct{}
-
- func (p *JobSchedulerService) GetResources(req *dto.JobGetResourceReq, header http.Header) ([]dto.JobGetResourceResp, *exports.CommResponse, error) {
- defer utils.TimeCost(time.Now(), "IamService.RegisterEndpoints")
- urlpath := configs.GetAppConfig().Resources.Iam + "/endpoints"
- u, _ := url.Parse(urlpath)
-
- b, _ := json.Marshal(req)
- fmt.Println(string(b))
- r := bytes.NewReader(b)
- u.RawQuery = ParseQueryFromStruct(*req)
-
- resp, err := DoRequest(u.String(), "POST", header, r)
-
- if err != nil {
- return nil, nil, err
- }
- resp1 := []dto.JobGetResourceResp{}
- s := dto.BaseListResp{Items: &resp1}
- commResponse, err := ParseResponse(resp, &s)
- return resp1, commResponse, err
- }
|