|
7 | 7 | context "context" |
8 | 8 | json "encoding/json" |
9 | 9 | errors "errors" |
10 | | - fmt "fmt" |
11 | | - uuid "github.com/google/uuid" |
12 | 10 | io "io" |
13 | 11 | http "net/http" |
14 | 12 | sdk "sdk" |
@@ -112,79 +110,3 @@ func (c *Client) Validate(ctx context.Context, request *cloud.ValidateGroupReque |
112 | 110 | } |
113 | 111 | return response, nil |
114 | 112 | } |
115 | | - |
116 | | -// Converts the given group into a developer group. |
117 | | -func (c *Client) ConvertGroup(ctx context.Context, groupId uuid.UUID) error { |
118 | | - baseURL := "https://api.rivet.gg" |
119 | | - if c.baseURL != "" { |
120 | | - baseURL = c.baseURL |
121 | | - } |
122 | | - endpointURL := fmt.Sprintf(baseURL+"/"+"cloud/groups/%v/convert", groupId) |
123 | | - |
124 | | - errorDecoder := func(statusCode int, body io.Reader) error { |
125 | | - raw, err := io.ReadAll(body) |
126 | | - if err != nil { |
127 | | - return err |
128 | | - } |
129 | | - apiError := core.NewAPIError(statusCode, errors.New(string(raw))) |
130 | | - decoder := json.NewDecoder(bytes.NewReader(raw)) |
131 | | - switch statusCode { |
132 | | - case 500: |
133 | | - value := new(sdk.InternalError) |
134 | | - value.APIError = apiError |
135 | | - if err := decoder.Decode(value); err != nil { |
136 | | - return apiError |
137 | | - } |
138 | | - return value |
139 | | - case 429: |
140 | | - value := new(sdk.RateLimitError) |
141 | | - value.APIError = apiError |
142 | | - if err := decoder.Decode(value); err != nil { |
143 | | - return apiError |
144 | | - } |
145 | | - return value |
146 | | - case 403: |
147 | | - value := new(sdk.ForbiddenError) |
148 | | - value.APIError = apiError |
149 | | - if err := decoder.Decode(value); err != nil { |
150 | | - return apiError |
151 | | - } |
152 | | - return value |
153 | | - case 408: |
154 | | - value := new(sdk.UnauthorizedError) |
155 | | - value.APIError = apiError |
156 | | - if err := decoder.Decode(value); err != nil { |
157 | | - return apiError |
158 | | - } |
159 | | - return value |
160 | | - case 404: |
161 | | - value := new(sdk.NotFoundError) |
162 | | - value.APIError = apiError |
163 | | - if err := decoder.Decode(value); err != nil { |
164 | | - return apiError |
165 | | - } |
166 | | - return value |
167 | | - case 400: |
168 | | - value := new(sdk.BadRequestError) |
169 | | - value.APIError = apiError |
170 | | - if err := decoder.Decode(value); err != nil { |
171 | | - return apiError |
172 | | - } |
173 | | - return value |
174 | | - } |
175 | | - return apiError |
176 | | - } |
177 | | - |
178 | | - if err := c.caller.Call( |
179 | | - ctx, |
180 | | - &core.CallParams{ |
181 | | - URL: endpointURL, |
182 | | - Method: http.MethodPost, |
183 | | - Headers: c.header, |
184 | | - ErrorDecoder: errorDecoder, |
185 | | - }, |
186 | | - ); err != nil { |
187 | | - return err |
188 | | - } |
189 | | - return nil |
190 | | -} |
0 commit comments