You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/08/08 01:43:39 UTC

[GitHub] [apisix-dashboard] Baoyuantop commented on a diff in pull request #2570: feat: add Admin API storage implementation

Baoyuantop commented on code in PR #2570:
URL: https://github.com/apache/apisix-dashboard/pull/2570#discussion_r939759655


##########
api/internal/core/storage/adminapi.go:
##########
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package storage
+
+import (
+	"context"
+	"fmt"
+	"strings"
+	"time"
+
+	"github.com/go-resty/resty/v2"
+	"github.com/pkg/errors"
+	"github.com/tidwall/gjson"
+
+	"github.com/apache/apisix-dashboard/api/pkg/storage"
+)
+
+const (
+	adminAPIErrorWarp = "failed to request Admin API"
+)
+
+type adminAPIVersion = int
+
+const (
+	adminAPIVersion2 adminAPIVersion = 2
+	adminApiVersion3 adminAPIVersion = 3
+)
+
+// Ensure that the AdminAPI Storage implementation conforms to the storage_api interface definition
+var _ storage_api.Interface = AdminAPIStorage{}
+
+// NewAdminAPIStorage will create an instance of AdminAPIStorage and complete the basic configure
+func NewAdminAPIStorage() *AdminAPIStorage {
+	return &AdminAPIStorage{
+		client: resty.New().
+			SetBaseURL("http://127.0.0.1:9080/apisix/admin/").
+			SetHeader("X-API-KEY", "edd1c9f034335f136f87ad84b625c8f1").
+			SetTimeout(1 * time.Second),
+	}

Review Comment:
   Do we need to move them into the config file?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org