зеркало из https://github.com/Azure/ARO-RP.git
Added an endpoint to list available versions to install. Currently it responds with hardcoded data
This commit is contained in:
Родитель
98fc429ece
Коммит
25590c623f
|
@ -1,4 +1,4 @@
|
|||
468fa0da0a50d50640ec57843ad288af343128b39f5bf23e76e4e336580883d4 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2020-04-30/redhatopenshift.json
|
||||
c323c84befa5ea11da50a2407050abed6540ea01e796720bc2241604ce80567c swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2021-09-01-preview/redhatopenshift.json
|
||||
e4e522e41855de71c0318db31cbd96c8713e7a74e7c81911bb494f0b194b3f43 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2022-04-01/redhatopenshift.json
|
||||
02a3d9195980130b1f3835fed62619eea32f8eb457ef23f8f8d36d2eb1ddab85 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2022-09-04/redhatopenshift.json
|
||||
5400ee6925f39c1b239fe7de76ca0723589b2f3e703879e6b8930b1bf7a661c5 swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2022-09-04/redhatopenshift.json
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package api
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
// InstallOpenShiftVersions represents a List of OpenShift installable versions.
|
||||
type InstallOpenShiftVersions []string
|
|
@ -25,6 +25,9 @@ type OpenShiftVersionConverter interface {
|
|||
ToExternal(*OpenShiftVersion) interface{}
|
||||
ToExternalList([]*OpenShiftVersion) interface{}
|
||||
}
|
||||
type InstallOpenShiftVersionsConverter interface {
|
||||
ToExternal(*InstallOpenShiftVersions) interface{}
|
||||
}
|
||||
|
||||
// Version is a set of endpoints implemented by each API version
|
||||
type Version struct {
|
||||
|
@ -33,6 +36,7 @@ type Version struct {
|
|||
OpenShiftClusterCredentialsConverter func() OpenShiftClusterCredentialsConverter
|
||||
OpenShiftClusterAdminKubeconfigConverter func() OpenShiftClusterAdminKubeconfigConverter
|
||||
OpenShiftVersionConverter func() OpenShiftVersionConverter
|
||||
InstallOpenShiftVersionsConverter func() InstallOpenShiftVersionsConverter
|
||||
}
|
||||
|
||||
// APIs is the map of registered API versions
|
||||
|
|
|
@ -36,6 +36,9 @@ type OpenShiftCluster struct {
|
|||
|
||||
// The cluster properties.
|
||||
Properties OpenShiftClusterProperties `json:"properties,omitempty"`
|
||||
|
||||
// The cluster install version.
|
||||
InstallVersion string `json:"installVersion,omitempty"`
|
||||
}
|
||||
|
||||
// Tags represents an OpenShift cluster's tags.
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package v20220904
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
// InstallOpenShiftVersions represents a List of OpenShift installable versions.
|
||||
type InstallOpenShiftVersions []string
|
|
@ -0,0 +1,18 @@
|
|||
package v20220904
|
||||
|
||||
import "github.com/Azure/ARO-RP/pkg/api"
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
type installOpenShiftVersionsConverter struct{}
|
||||
|
||||
// TODO: Change the comment
|
||||
// OpenShiftClusterCredentialsToExternal returns a new external representation
|
||||
// of the internal object, reading from the subset of the internal object's
|
||||
// fields that appear in the external representation. ToExternal does not
|
||||
// modify its argument; there is no pointer aliasing between the passed and
|
||||
// returned objects.
|
||||
func (*installOpenShiftVersionsConverter) ToExternal(iov *api.InstallOpenShiftVersions) interface{} {
|
||||
return iov
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package v20220904
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
// ExampleInstallOpenShiftVersions returns an example
|
||||
// InstallOpenShiftVersions object i.e []string that the RP would return to an end-user.
|
||||
func ExampleInstallOpenShiftVersionsResponse() interface{} {
|
||||
return &InstallOpenShiftVersions{"4.10.20"}
|
||||
}
|
|
@ -34,5 +34,8 @@ func init() {
|
|||
OpenShiftClusterAdminKubeconfigConverter: func() api.OpenShiftClusterAdminKubeconfigConverter {
|
||||
return &openShiftClusterAdminKubeconfigConverter{}
|
||||
},
|
||||
InstallOpenShiftVersionsConverter: func() api.InstallOpenShiftVersionsConverter {
|
||||
return &installOpenShiftVersionsConverter{}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
package redhatopenshift
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// Licensed 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.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/tracing"
|
||||
)
|
||||
|
||||
// ListClient is the rest API for Azure Red Hat OpenShift 4
|
||||
type ListClient struct {
|
||||
BaseClient
|
||||
}
|
||||
|
||||
// NewListClient creates an instance of the ListClient client.
|
||||
func NewListClient(subscriptionID string) ListClient {
|
||||
return NewListClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||
}
|
||||
|
||||
// NewListClientWithBaseURI creates an instance of the ListClient client using a custom endpoint. Use this when
|
||||
// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
|
||||
func NewListClientWithBaseURI(baseURI string, subscriptionID string) ListClient {
|
||||
return ListClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// Versions the operation returns the installable OpenShift versions as strings.
|
||||
func (client ListClient) Versions(ctx context.Context) (result SetObject, err error) {
|
||||
if tracing.IsEnabled() {
|
||||
ctx = tracing.StartSpan(ctx, fqdn+"/ListClient.Versions")
|
||||
defer func() {
|
||||
sc := -1
|
||||
if result.Response.Response != nil {
|
||||
sc = result.Response.Response.StatusCode
|
||||
}
|
||||
tracing.EndSpan(ctx, sc, err)
|
||||
}()
|
||||
}
|
||||
req, err := client.VersionsPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.ListClient", "Versions", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.VersionsSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.ListClient", "Versions", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.VersionsResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.ListClient", "Versions", resp, "Failure responding to request")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// VersionsPreparer prepares the Versions request.
|
||||
func (client ListClient) VersionsPreparer(ctx context.Context) (*http.Request, error) {
|
||||
const APIVersion = "2022-09-04"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPath("/providers/Microsoft.RedHatOpenShift/listinstallopenshiftversions"),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// VersionsSender sends the Versions request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ListClient) VersionsSender(req *http.Request) (*http.Response, error) {
|
||||
return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
|
||||
}
|
||||
|
||||
// VersionsResponder handles the response to the Versions request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ListClient) VersionsResponder(resp *http.Response) (result SetObject, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result.Value),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
|
@ -581,6 +581,8 @@ type OpenShiftClusterUpdate struct {
|
|||
Tags map[string]*string `json:"tags"`
|
||||
// OpenShiftClusterProperties - The cluster properties.
|
||||
*OpenShiftClusterProperties `json:"properties,omitempty"`
|
||||
// InstallVersion - The cluster install version.
|
||||
InstallVersion *string `json:"installVersion,omitempty"`
|
||||
// SystemData - READ-ONLY; The system meta data relating to this resource.
|
||||
SystemData *SystemData `json:"systemData,omitempty"`
|
||||
}
|
||||
|
@ -594,6 +596,9 @@ func (oscu OpenShiftClusterUpdate) MarshalJSON() ([]byte, error) {
|
|||
if oscu.OpenShiftClusterProperties != nil {
|
||||
objectMap["properties"] = oscu.OpenShiftClusterProperties
|
||||
}
|
||||
if oscu.InstallVersion != nil {
|
||||
objectMap["installVersion"] = oscu.InstallVersion
|
||||
}
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
|
@ -624,6 +629,15 @@ func (oscu *OpenShiftClusterUpdate) UnmarshalJSON(body []byte) error {
|
|||
}
|
||||
oscu.OpenShiftClusterProperties = &openShiftClusterProperties
|
||||
}
|
||||
case "installVersion":
|
||||
if v != nil {
|
||||
var installVersion string
|
||||
err = json.Unmarshal(*v, &installVersion)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
oscu.InstallVersion = &installVersion
|
||||
}
|
||||
case "systemData":
|
||||
if v != nil {
|
||||
var systemData SystemData
|
||||
|
@ -849,6 +863,12 @@ type ServicePrincipalProfile struct {
|
|||
ClientSecret *string `json:"clientSecret,omitempty"`
|
||||
}
|
||||
|
||||
// SetObject ...
|
||||
type SetObject struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value interface{} `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// SystemData metadata pertaining to creation and last modification of the resource.
|
||||
type SystemData struct {
|
||||
// CreatedBy - The identity that created the resource.
|
||||
|
|
|
@ -311,125 +311,6 @@ func (client OpenShiftClustersClient) GetResponder(resp *http.Response) (result
|
|||
return
|
||||
}
|
||||
|
||||
// List the operation returns properties of each OpenShift cluster.
|
||||
func (client OpenShiftClustersClient) List(ctx context.Context) (result OpenShiftClusterListPage, err error) {
|
||||
if tracing.IsEnabled() {
|
||||
ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.List")
|
||||
defer func() {
|
||||
sc := -1
|
||||
if result.oscl.Response.Response != nil {
|
||||
sc = result.oscl.Response.Response.StatusCode
|
||||
}
|
||||
tracing.EndSpan(ctx, sc, err)
|
||||
}()
|
||||
}
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: client.SubscriptionID,
|
||||
Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "List", err.Error())
|
||||
}
|
||||
|
||||
result.fn = client.listNextResults
|
||||
req, err := client.ListPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.oscl.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.oscl, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", resp, "Failure responding to request")
|
||||
return
|
||||
}
|
||||
if result.oscl.hasNextLink() && result.oscl.IsEmpty() {
|
||||
err = result.NextWithContext(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client OpenShiftClustersClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2022-09-04"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client OpenShiftClustersClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
return client.Send(req, azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListResponder handles the response to the List request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client OpenShiftClustersClient) ListResponder(resp *http.Response) (result OpenShiftClusterList, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listNextResults retrieves the next set of results, if any.
|
||||
func (client OpenShiftClustersClient) listNextResults(ctx context.Context, lastResults OpenShiftClusterList) (result OpenShiftClusterList, err error) {
|
||||
req, err := lastResults.openShiftClusterListPreparer(ctx)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client OpenShiftClustersClient) ListComplete(ctx context.Context) (result OpenShiftClusterListIterator, err error) {
|
||||
if tracing.IsEnabled() {
|
||||
ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.List")
|
||||
defer func() {
|
||||
sc := -1
|
||||
if result.Response().Response.Response != nil {
|
||||
sc = result.page.Response().Response.Response.StatusCode
|
||||
}
|
||||
tracing.EndSpan(ctx, sc, err)
|
||||
}()
|
||||
}
|
||||
result.page, err = client.List(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
// ListAdminCredentials the operation returns the admin kubeconfig.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group. The name is case insensitive.
|
||||
|
@ -728,6 +609,125 @@ func (client OpenShiftClustersClient) ListCredentialsResponder(resp *http.Respon
|
|||
return
|
||||
}
|
||||
|
||||
// ListMethod the operation returns properties of each OpenShift cluster.
|
||||
func (client OpenShiftClustersClient) ListMethod(ctx context.Context) (result OpenShiftClusterListPage, err error) {
|
||||
if tracing.IsEnabled() {
|
||||
ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListMethod")
|
||||
defer func() {
|
||||
sc := -1
|
||||
if result.oscl.Response.Response != nil {
|
||||
sc = result.oscl.Response.Response.StatusCode
|
||||
}
|
||||
tracing.EndSpan(ctx, sc, err)
|
||||
}()
|
||||
}
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: client.SubscriptionID,
|
||||
Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "ListMethod", err.Error())
|
||||
}
|
||||
|
||||
result.fn = client.listMethodNextResults
|
||||
req, err := client.ListMethodPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListMethod", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListMethodSender(req)
|
||||
if err != nil {
|
||||
result.oscl.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListMethod", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.oscl, err = client.ListMethodResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListMethod", resp, "Failure responding to request")
|
||||
return
|
||||
}
|
||||
if result.oscl.hasNextLink() && result.oscl.IsEmpty() {
|
||||
err = result.NextWithContext(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListMethodPreparer prepares the ListMethod request.
|
||||
func (client OpenShiftClustersClient) ListMethodPreparer(ctx context.Context) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
const APIVersion = "2022-09-04"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListMethodSender sends the ListMethod request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client OpenShiftClustersClient) ListMethodSender(req *http.Request) (*http.Response, error) {
|
||||
return client.Send(req, azure.DoRetryWithRegistration(client.Client))
|
||||
}
|
||||
|
||||
// ListMethodResponder handles the response to the ListMethod request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client OpenShiftClustersClient) ListMethodResponder(resp *http.Response) (result OpenShiftClusterList, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// listMethodNextResults retrieves the next set of results, if any.
|
||||
func (client OpenShiftClustersClient) listMethodNextResults(ctx context.Context, lastResults OpenShiftClusterList) (result OpenShiftClusterList, err error) {
|
||||
req, err := lastResults.openShiftClusterListPreparer(ctx)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listMethodNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListMethodSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listMethodNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListMethodResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listMethodNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListMethodComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client OpenShiftClustersClient) ListMethodComplete(ctx context.Context) (result OpenShiftClusterListIterator, err error) {
|
||||
if tracing.IsEnabled() {
|
||||
ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListMethod")
|
||||
defer func() {
|
||||
sc := -1
|
||||
if result.Response().Response.Response != nil {
|
||||
sc = result.page.Response().Response.Response.StatusCode
|
||||
}
|
||||
tracing.EndSpan(ctx, sc, err)
|
||||
}()
|
||||
}
|
||||
result.page, err = client.ListMethod(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
// Update the operation returns properties of a OpenShift cluster.
|
||||
// Parameters:
|
||||
// resourceGroupName - the name of the resource group. The name is case insensitive.
|
||||
|
|
|
@ -42,10 +42,10 @@ func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) Opera
|
|||
return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||
}
|
||||
|
||||
// List the operation returns the RP operations.
|
||||
func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) {
|
||||
// ListMethod the operation returns the RP operations.
|
||||
func (client OperationsClient) ListMethod(ctx context.Context) (result OperationListPage, err error) {
|
||||
if tracing.IsEnabled() {
|
||||
ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List")
|
||||
ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.ListMethod")
|
||||
defer func() {
|
||||
sc := -1
|
||||
if result.ol.Response.Response != nil {
|
||||
|
@ -54,23 +54,23 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListPa
|
|||
tracing.EndSpan(ctx, sc, err)
|
||||
}()
|
||||
}
|
||||
result.fn = client.listNextResults
|
||||
req, err := client.ListPreparer(ctx)
|
||||
result.fn = client.listMethodNextResults
|
||||
req, err := client.ListMethodPreparer(ctx)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", nil, "Failure preparing request")
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "ListMethod", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
resp, err := client.ListMethodSender(req)
|
||||
if err != nil {
|
||||
result.ol.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", resp, "Failure sending request")
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "ListMethod", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result.ol, err = client.ListResponder(resp)
|
||||
result.ol, err = client.ListMethodResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", resp, "Failure responding to request")
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "ListMethod", resp, "Failure responding to request")
|
||||
return
|
||||
}
|
||||
if result.ol.hasNextLink() && result.ol.IsEmpty() {
|
||||
|
@ -81,8 +81,8 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListPa
|
|||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||
// ListMethodPreparer prepares the ListMethod request.
|
||||
func (client OperationsClient) ListMethodPreparer(ctx context.Context) (*http.Request, error) {
|
||||
const APIVersion = "2022-09-04"
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": APIVersion,
|
||||
|
@ -96,15 +96,15 @@ func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request,
|
|||
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// ListMethodSender sends the ListMethod request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
func (client OperationsClient) ListMethodSender(req *http.Request) (*http.Response, error) {
|
||||
return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
|
||||
}
|
||||
|
||||
// ListResponder handles the response to the List request. The method always
|
||||
// ListMethodResponder handles the response to the ListMethod request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) {
|
||||
func (client OperationsClient) ListMethodResponder(resp *http.Response) (result OperationList, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
|
@ -114,31 +114,31 @@ func (client OperationsClient) ListResponder(resp *http.Response) (result Operat
|
|||
return
|
||||
}
|
||||
|
||||
// listNextResults retrieves the next set of results, if any.
|
||||
func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) {
|
||||
// listMethodNextResults retrieves the next set of results, if any.
|
||||
func (client OperationsClient) listMethodNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) {
|
||||
req, err := lastResults.operationListPreparer(ctx)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||
return result, autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listMethodNextResults", nil, "Failure preparing next results request")
|
||||
}
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
resp, err := client.ListSender(req)
|
||||
resp, err := client.ListMethodSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listNextResults", resp, "Failure sending next results request")
|
||||
return result, autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listMethodNextResults", resp, "Failure sending next results request")
|
||||
}
|
||||
result, err = client.ListResponder(resp)
|
||||
result, err = client.ListMethodResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||
err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listMethodNextResults", resp, "Failure responding to next results request")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) {
|
||||
// ListMethodComplete enumerates all values, automatically crossing page boundaries as required.
|
||||
func (client OperationsClient) ListMethodComplete(ctx context.Context) (result OperationListIterator, err error) {
|
||||
if tracing.IsEnabled() {
|
||||
ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List")
|
||||
ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.ListMethod")
|
||||
defer func() {
|
||||
sc := -1
|
||||
if result.Response().Response.Response != nil {
|
||||
|
@ -147,6 +147,6 @@ func (client OperationsClient) ListComplete(ctx context.Context) (result Operati
|
|||
tracing.EndSpan(ctx, sc, err)
|
||||
}()
|
||||
}
|
||||
result.page, err = client.List(ctx)
|
||||
result.page, err = client.ListMethod(ctx)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -23,10 +23,17 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2022-09-04/redhatopenshift"
|
||||
)
|
||||
|
||||
// ListClientAPI contains the set of methods on the ListClient type.
|
||||
type ListClientAPI interface {
|
||||
Versions(ctx context.Context) (result redhatopenshift.SetObject, err error)
|
||||
}
|
||||
|
||||
var _ ListClientAPI = (*redhatopenshift.ListClient)(nil)
|
||||
|
||||
// OperationsClientAPI contains the set of methods on the OperationsClient type.
|
||||
type OperationsClientAPI interface {
|
||||
List(ctx context.Context) (result redhatopenshift.OperationListPage, err error)
|
||||
ListComplete(ctx context.Context) (result redhatopenshift.OperationListIterator, err error)
|
||||
ListMethod(ctx context.Context) (result redhatopenshift.OperationListPage, err error)
|
||||
ListMethodComplete(ctx context.Context) (result redhatopenshift.OperationListIterator, err error)
|
||||
}
|
||||
|
||||
var _ OperationsClientAPI = (*redhatopenshift.OperationsClient)(nil)
|
||||
|
@ -36,12 +43,12 @@ type OpenShiftClustersClientAPI interface {
|
|||
CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters redhatopenshift.OpenShiftCluster) (result redhatopenshift.OpenShiftClustersCreateOrUpdateFuture, err error)
|
||||
Delete(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClustersDeleteFuture, err error)
|
||||
Get(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftCluster, err error)
|
||||
List(ctx context.Context) (result redhatopenshift.OpenShiftClusterListPage, err error)
|
||||
ListComplete(ctx context.Context) (result redhatopenshift.OpenShiftClusterListIterator, err error)
|
||||
ListAdminCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClusterAdminKubeconfig, err error)
|
||||
ListByResourceGroup(ctx context.Context, resourceGroupName string) (result redhatopenshift.OpenShiftClusterListPage, err error)
|
||||
ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result redhatopenshift.OpenShiftClusterListIterator, err error)
|
||||
ListCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClusterCredentials, err error)
|
||||
ListMethod(ctx context.Context) (result redhatopenshift.OpenShiftClusterListPage, err error)
|
||||
ListMethodComplete(ctx context.Context) (result redhatopenshift.OpenShiftClusterListIterator, err error)
|
||||
Update(ctx context.Context, resourceGroupName string, resourceName string, parameters redhatopenshift.OpenShiftClusterUpdate) (result redhatopenshift.OpenShiftClustersUpdateFuture, err error)
|
||||
}
|
||||
|
||||
|
|
|
@ -217,6 +217,13 @@ func (f *frontend) authenticatedRoutes(r *mux.Router) {
|
|||
|
||||
s.Methods(http.MethodPost).HandlerFunc(f.postOpenShiftClusterKubeConfigCredentials).Name("postOpenShiftClusterKubeConfigCredentials")
|
||||
|
||||
s = r.
|
||||
Path("/providers/{resourceProviderNamespace}/listinstallopenshiftversions").
|
||||
Queries("api-version", "{api-version}").
|
||||
Subrouter()
|
||||
|
||||
s.Methods(http.MethodGet).HandlerFunc(f.listInstallOpenShiftVersions).Name("listInstallOpenShiftVersions")
|
||||
|
||||
// Admin actions
|
||||
s = r.
|
||||
Path("/admin/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/kubernetesobjects").
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package frontend
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/frontend/middleware"
|
||||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
)
|
||||
|
||||
func (f *frontend) listInstallOpenShiftVersions(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
vars := mux.Vars(r)
|
||||
log := ctx.Value(middleware.ContextKeyLog).(*logrus.Entry)
|
||||
|
||||
if f.apis[vars["api-version"]].InstallOpenShiftVersionsConverter == nil {
|
||||
api.WriteError(w, http.StatusBadRequest, api.CloudErrorCodeInvalidResourceType, "", "The endpoint could not be found in the namespace '%s' for api version '%s'.", vars["resourceProviderNamespace"], vars["api-version"])
|
||||
return
|
||||
}
|
||||
|
||||
versions := f.getInstallOpenShiftVersions()
|
||||
converter := f.apis[vars["api-version"]].InstallOpenShiftVersionsConverter()
|
||||
|
||||
b, err := json.Marshal(converter.ToExternal((*api.InstallOpenShiftVersions)(&versions)))
|
||||
reply(log, w, nil, b, err)
|
||||
}
|
||||
|
||||
// Creating this separate method so that it can be reused while doing some other stuff like validating the install version against available version.
|
||||
func (f *frontend) getInstallOpenShiftVersions() []string {
|
||||
// TODO: Currently, the versions are hard coded and being pulled from version.UpgradeStreams, but in future they will be pulled from cosmosdb.
|
||||
installStream := version.InstallStream
|
||||
versions := make([]string, 0)
|
||||
versions = append(versions, installStream.Version.String())
|
||||
|
||||
return versions
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package frontend
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
v20220904 "github.com/Azure/ARO-RP/pkg/api/v20220904"
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
"github.com/Azure/ARO-RP/pkg/frontend/adminactions"
|
||||
"github.com/Azure/ARO-RP/pkg/metrics/noop"
|
||||
mock_adminactions "github.com/Azure/ARO-RP/pkg/util/mocks/adminactions"
|
||||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
)
|
||||
|
||||
func TestListInstallableVersions(t *testing.T) {
|
||||
mockSubID := "00000000-0000-0000-0000-000000000000"
|
||||
mockTenantID := "00000000-0000-0000-0000-000000000000"
|
||||
method := http.MethodGet
|
||||
ctx := context.Background()
|
||||
|
||||
type test struct {
|
||||
name string
|
||||
mocks func(*test, *mock_adminactions.MockKubeActions)
|
||||
wantStatusCode int
|
||||
wantResponse *v20220904.InstallOpenShiftVersions
|
||||
wantResponseContentType string
|
||||
wantError string
|
||||
}
|
||||
|
||||
for _, tt := range []*test{
|
||||
{
|
||||
name: "hard coded versions",
|
||||
mocks: func(t *test, mka *mock_adminactions.MockKubeActions) {},
|
||||
wantStatusCode: http.StatusOK,
|
||||
wantResponseContentType: "application/json",
|
||||
wantResponse: &v20220904.InstallOpenShiftVersions{version.InstallStream.Version.String()},
|
||||
},
|
||||
} {
|
||||
t.Run(fmt.Sprintf("%s: %s", method, tt.name), func(t *testing.T) {
|
||||
resourceProviderNamespace := "Microsoft.RedHatOpenShift"
|
||||
ti := newTestInfra(t).WithSubscriptions()
|
||||
defer ti.done()
|
||||
ti.fixture.AddSubscriptionDocuments(&api.SubscriptionDocument{
|
||||
ID: mockSubID,
|
||||
Subscription: &api.Subscription{
|
||||
State: api.SubscriptionStateRegistered,
|
||||
Properties: &api.SubscriptionProperties{
|
||||
TenantID: mockTenantID,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
err := ti.buildFixtures(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
f, err := NewFrontend(ctx, ti.audit, ti.log, ti.env, ti.asyncOperationsDatabase, ti.openShiftClustersDatabase, ti.subscriptionsDatabase, api.APIs, &noop.Noop{}, nil, func(*logrus.Entry, env.Interface, *api.OpenShiftCluster) (adminactions.KubeActions, error) {
|
||||
return nil, nil
|
||||
}, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
go f.Run(ctx, nil, nil)
|
||||
|
||||
resp, b, err := ti.request(method,
|
||||
fmt.Sprintf("https://server//providers/%s/listinstallopenshiftversions?api-version=2022-09-04", resourceProviderNamespace),
|
||||
nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
b = bytes.TrimSpace(b)
|
||||
|
||||
err = validateResponse(resp, b, tt.wantStatusCode, tt.wantError, tt.wantResponse)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if tt.wantResponseContentType != resp.Header.Get("Content-Type") {
|
||||
t.Error(fmt.Errorf("unexpected \"Content-Type\" response header value \"%s\", wanted \"%s\"", resp.Header.Get("Content-Type"), tt.wantResponseContentType))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -90,6 +90,15 @@ func (f *frontend) getOperations(w http.ResponseWriter, r *http.Request) {
|
|||
},
|
||||
Origin: "user,system",
|
||||
},
|
||||
{
|
||||
Name: "Microsoft.RedHatOpenShift/listInstallOpenShiftVersions/read",
|
||||
Display: api.Display{
|
||||
Provider: "Azure Red Hat OpenShift",
|
||||
Resource: "listInstallOpenShiftVersions",
|
||||
Operation: "Lists all OpenShift versions available to install",
|
||||
},
|
||||
Origin: "user,system",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -25,14 +25,16 @@ type generator struct {
|
|||
exampleOpenShiftClusterCredentialsResponse func() interface{}
|
||||
exampleOpenShiftClusterAdminKubeconfigResponse func() interface{}
|
||||
exampleOpenShiftClusterListResponse func() interface{}
|
||||
exampleInstallOpenShiftVersions func() interface{}
|
||||
exampleOperationListResponse func() interface{}
|
||||
|
||||
systemData bool
|
||||
kubeConfig bool
|
||||
xmsEnum []string
|
||||
xmsSecretList []string
|
||||
xmsIdentifiers []string
|
||||
commonTypesVersion string
|
||||
systemData bool
|
||||
kubeConfig bool
|
||||
installableOpenShiftVersion bool
|
||||
xmsEnum []string
|
||||
xmsSecretList []string
|
||||
xmsIdentifiers []string
|
||||
commonTypesVersion string
|
||||
}
|
||||
|
||||
var apis = map[string]*generator{
|
||||
|
@ -85,14 +87,16 @@ var apis = map[string]*generator{
|
|||
exampleOpenShiftClusterCredentialsResponse: v20220904.ExampleOpenShiftClusterCredentialsResponse,
|
||||
exampleOpenShiftClusterListResponse: v20220904.ExampleOpenShiftClusterListResponse,
|
||||
exampleOpenShiftClusterAdminKubeconfigResponse: v20220904.ExampleOpenShiftClusterAdminKubeconfigResponse,
|
||||
exampleInstallOpenShiftVersions: v20220904.ExampleInstallOpenShiftVersionsResponse,
|
||||
exampleOperationListResponse: api.ExampleOperationListResponse,
|
||||
|
||||
xmsEnum: []string{"EncryptionAtHost", "FipsValidatedModules", "SoftwareDefinedNetwork", "Visibility"},
|
||||
xmsSecretList: []string{"kubeconfig", "kubeadminPassword"},
|
||||
xmsIdentifiers: []string{},
|
||||
commonTypesVersion: "v2",
|
||||
systemData: true,
|
||||
kubeConfig: true,
|
||||
xmsEnum: []string{"EncryptionAtHost", "FipsValidatedModules", "SoftwareDefinedNetwork", "Visibility"},
|
||||
xmsSecretList: []string{"kubeconfig", "kubeadminPassword"},
|
||||
xmsIdentifiers: []string{},
|
||||
commonTypesVersion: "v2",
|
||||
systemData: true,
|
||||
installableOpenShiftVersion: true,
|
||||
kubeConfig: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -89,12 +89,30 @@ func Run(api, outputDir string) error {
|
|||
},
|
||||
}
|
||||
|
||||
// for installaOpenShiftVerions
|
||||
if g.installableOpenShiftVersion {
|
||||
s.Paths["/providers/Microsoft.RedHatOpenShift/listinstallopenshiftversions"] = &PathItem{
|
||||
Get: &Operation{
|
||||
Tags: []string{"InstallOpenShiftVersions"},
|
||||
Summary: "Lists all OpenShift versions available to install.",
|
||||
Description: "The operation returns the installable OpenShift versions as strings.",
|
||||
OperationID: "List_Installable_OpenShift_Versions",
|
||||
Parameters: g.populateParameters(0, "InstallOpenShiftVersions", "Install OpenShift Versions"),
|
||||
Responses: g.populateResponses("InstallOpenShiftVersions", false, http.StatusOK),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
populateExamples(s.Paths)
|
||||
names := []string{"OpenShiftClusterList", "OpenShiftClusterCredentials"}
|
||||
if g.kubeConfig {
|
||||
names = append(names, "OpenShiftClusterAdminKubeconfig")
|
||||
}
|
||||
|
||||
if g.installableOpenShiftVersion {
|
||||
names = append(names, "InstallOpenShiftVersions")
|
||||
}
|
||||
|
||||
err = define(s.Definitions, api, g.xmsEnum, g.xmsSecretList, g.xmsIdentifiers, names...)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -23,7 +23,7 @@ from azure.mgmt.core import ARMPipelineClient
|
|||
|
||||
from . import models
|
||||
from ._configuration import AzureRedHatOpenShiftClientConfiguration
|
||||
from .operations import OpenShiftClustersOperations, Operations
|
||||
from .operations import ListOperations, OpenShiftClustersOperations, Operations
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# pylint: disable=unused-import,ungrouped-imports
|
||||
|
@ -35,6 +35,8 @@ if TYPE_CHECKING:
|
|||
class AzureRedHatOpenShiftClient(object):
|
||||
"""Rest API for Azure Red Hat OpenShift 4.
|
||||
|
||||
:ivar list: ListOperations operations
|
||||
:vartype list: azure.mgmt.redhatopenshift.v2022_09_04.operations.ListOperations
|
||||
:ivar operations: Operations operations
|
||||
:vartype operations: azure.mgmt.redhatopenshift.v2022_09_04.operations.Operations
|
||||
:ivar open_shift_clusters: OpenShiftClustersOperations operations
|
||||
|
@ -68,6 +70,7 @@ class AzureRedHatOpenShiftClient(object):
|
|||
self._serialize = Serializer(client_models)
|
||||
self._deserialize = Deserializer(client_models)
|
||||
self._serialize.client_side_validation = False
|
||||
self.list = ListOperations(self._client, self._config, self._serialize, self._deserialize)
|
||||
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
|
||||
self.open_shift_clusters = OpenShiftClustersOperations(self._client, self._config, self._serialize, self._deserialize)
|
||||
|
||||
|
|
|
@ -628,6 +628,8 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
|
|||
|
||||
:ivar tags: A set of tags. The resource tags.
|
||||
:vartype tags: dict[str, str]
|
||||
:ivar install_version: The cluster install version.
|
||||
:vartype install_version: str
|
||||
:ivar system_data: The system meta data relating to this resource.
|
||||
:vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData
|
||||
:ivar provisioning_state: The cluster provisioning state. Possible values include:
|
||||
|
@ -659,6 +661,7 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
|
|||
|
||||
_attribute_map = {
|
||||
'tags': {'key': 'tags', 'type': '{str}'},
|
||||
'install_version': {'key': 'installVersion', 'type': 'str'},
|
||||
'system_data': {'key': 'systemData', 'type': 'SystemData'},
|
||||
'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'},
|
||||
'cluster_profile': {'key': 'properties.clusterProfile', 'type': 'ClusterProfile'},
|
||||
|
@ -678,6 +681,8 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
|
|||
"""
|
||||
:keyword tags: A set of tags. The resource tags.
|
||||
:paramtype tags: dict[str, str]
|
||||
:keyword install_version: The cluster install version.
|
||||
:paramtype install_version: str
|
||||
:keyword provisioning_state: The cluster provisioning state. Possible values include:
|
||||
"AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating".
|
||||
:paramtype provisioning_state: str or
|
||||
|
@ -703,6 +708,7 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
|
|||
"""
|
||||
super(OpenShiftClusterUpdate, self).__init__(**kwargs)
|
||||
self.tags = kwargs.get('tags', None)
|
||||
self.install_version = kwargs.get('install_version', None)
|
||||
self.system_data = None
|
||||
self.provisioning_state = kwargs.get('provisioning_state', None)
|
||||
self.cluster_profile = kwargs.get('cluster_profile', None)
|
||||
|
|
|
@ -691,6 +691,8 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
|
|||
|
||||
:ivar tags: A set of tags. The resource tags.
|
||||
:vartype tags: dict[str, str]
|
||||
:ivar install_version: The cluster install version.
|
||||
:vartype install_version: str
|
||||
:ivar system_data: The system meta data relating to this resource.
|
||||
:vartype system_data: ~azure.mgmt.redhatopenshift.v2022_09_04.models.SystemData
|
||||
:ivar provisioning_state: The cluster provisioning state. Possible values include:
|
||||
|
@ -722,6 +724,7 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
|
|||
|
||||
_attribute_map = {
|
||||
'tags': {'key': 'tags', 'type': '{str}'},
|
||||
'install_version': {'key': 'installVersion', 'type': 'str'},
|
||||
'system_data': {'key': 'systemData', 'type': 'SystemData'},
|
||||
'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'},
|
||||
'cluster_profile': {'key': 'properties.clusterProfile', 'type': 'ClusterProfile'},
|
||||
|
@ -738,6 +741,7 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
|
|||
self,
|
||||
*,
|
||||
tags: Optional[Dict[str, str]] = None,
|
||||
install_version: Optional[str] = None,
|
||||
provisioning_state: Optional[Union[str, "ProvisioningState"]] = None,
|
||||
cluster_profile: Optional["ClusterProfile"] = None,
|
||||
console_profile: Optional["ConsoleProfile"] = None,
|
||||
|
@ -752,6 +756,8 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
|
|||
"""
|
||||
:keyword tags: A set of tags. The resource tags.
|
||||
:paramtype tags: dict[str, str]
|
||||
:keyword install_version: The cluster install version.
|
||||
:paramtype install_version: str
|
||||
:keyword provisioning_state: The cluster provisioning state. Possible values include:
|
||||
"AdminUpdating", "Creating", "Deleting", "Failed", "Succeeded", "Updating".
|
||||
:paramtype provisioning_state: str or
|
||||
|
@ -777,6 +783,7 @@ class OpenShiftClusterUpdate(msrest.serialization.Model):
|
|||
"""
|
||||
super(OpenShiftClusterUpdate, self).__init__(**kwargs)
|
||||
self.tags = tags
|
||||
self.install_version = install_version
|
||||
self.system_data = None
|
||||
self.provisioning_state = provisioning_state
|
||||
self.cluster_profile = cluster_profile
|
||||
|
|
|
@ -14,10 +14,12 @@
|
|||
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
from ._list_operations import ListOperations
|
||||
from ._operations import Operations
|
||||
from ._open_shift_clusters_operations import OpenShiftClustersOperations
|
||||
|
||||
__all__ = [
|
||||
'ListOperations',
|
||||
'Operations',
|
||||
'OpenShiftClustersOperations',
|
||||
]
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
# pylint: disable=too-many-lines
|
||||
# coding=utf-8
|
||||
# --------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed 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.
|
||||
#
|
||||
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
# --------------------------------------------------------------------------
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from msrest import Serializer
|
||||
|
||||
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
|
||||
from azure.core.pipeline import PipelineResponse
|
||||
from azure.core.pipeline.transport import HttpResponse
|
||||
from azure.core.rest import HttpRequest
|
||||
from azure.core.tracing.decorator import distributed_trace
|
||||
from azure.mgmt.core.exceptions import ARMErrorFormat
|
||||
|
||||
from .. import models as _models
|
||||
from .._vendor import _convert_request
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# pylint: disable=unused-import,ungrouped-imports
|
||||
from typing import Any, Callable, Dict, Optional, TypeVar
|
||||
T = TypeVar('T')
|
||||
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
|
||||
|
||||
_SERIALIZER = Serializer()
|
||||
_SERIALIZER.client_side_validation = False
|
||||
# fmt: off
|
||||
|
||||
def build_installable_open_shift_versions_request(
|
||||
**kwargs # type: Any
|
||||
):
|
||||
# type: (...) -> HttpRequest
|
||||
api_version = kwargs.pop('api_version', "2022-09-04") # type: str
|
||||
|
||||
accept = "application/json"
|
||||
# Construct URL
|
||||
_url = kwargs.pop("template_url", "/providers/Microsoft.RedHatOpenShift/listinstallopenshiftversions")
|
||||
|
||||
# Construct parameters
|
||||
_query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any]
|
||||
_query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str')
|
||||
|
||||
# Construct headers
|
||||
_header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
|
||||
_header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
|
||||
|
||||
return HttpRequest(
|
||||
method="GET",
|
||||
url=_url,
|
||||
params=_query_parameters,
|
||||
headers=_header_parameters,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
# fmt: on
|
||||
class ListOperations(object):
|
||||
"""ListOperations operations.
|
||||
|
||||
You should not instantiate this class directly. Instead, you should create a Client instance that
|
||||
instantiates it for you and attaches it as an attribute.
|
||||
|
||||
:ivar models: Alias to model classes used in this operation group.
|
||||
:type models: ~azure.mgmt.redhatopenshift.v2022_09_04.models
|
||||
:param client: Client for service requests.
|
||||
:param config: Configuration of service client.
|
||||
:param serializer: An object model serializer.
|
||||
:param deserializer: An object model deserializer.
|
||||
"""
|
||||
|
||||
models = _models
|
||||
|
||||
def __init__(self, client, config, serializer, deserializer):
|
||||
self._client = client
|
||||
self._serialize = serializer
|
||||
self._deserialize = deserializer
|
||||
self._config = config
|
||||
|
||||
@distributed_trace
|
||||
def installable_open_shift_versions(
|
||||
self,
|
||||
**kwargs # type: Any
|
||||
):
|
||||
# type: (...) -> Any
|
||||
"""Lists all OpenShift versions available to install.
|
||||
|
||||
The operation returns the installable OpenShift versions as strings.
|
||||
|
||||
:keyword callable cls: A custom type or function that will be passed the direct response
|
||||
:return: any, or the result of cls(response)
|
||||
:rtype: any
|
||||
:raises: ~azure.core.exceptions.HttpResponseError
|
||||
"""
|
||||
cls = kwargs.pop('cls', None) # type: ClsType[Any]
|
||||
error_map = {
|
||||
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
|
||||
}
|
||||
error_map.update(kwargs.pop('error_map', {}))
|
||||
|
||||
api_version = kwargs.pop('api_version', "2022-09-04") # type: str
|
||||
|
||||
|
||||
request = build_installable_open_shift_versions_request(
|
||||
api_version=api_version,
|
||||
template_url=self.installable_open_shift_versions.metadata['url'],
|
||||
)
|
||||
request = _convert_request(request)
|
||||
request.url = self._client.format_url(request.url)
|
||||
|
||||
pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access
|
||||
request,
|
||||
stream=False,
|
||||
**kwargs
|
||||
)
|
||||
response = pipeline_response.http_response
|
||||
|
||||
if response.status_code not in [200]:
|
||||
map_error(status_code=response.status_code, response=response, error_map=error_map)
|
||||
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
|
||||
|
||||
deserialized = self._deserialize('object', pipeline_response)
|
||||
|
||||
if cls:
|
||||
return cls(pipeline_response, deserialized, {})
|
||||
|
||||
return deserialized
|
||||
|
||||
installable_open_shift_versions.metadata = {'url': "/providers/Microsoft.RedHatOpenShift/listinstallopenshiftversions"} # type: ignore
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"parameters": {
|
||||
"api-version": "2022-09-04"
|
||||
},
|
||||
"responses": {
|
||||
"200": {}
|
||||
}
|
||||
}
|
|
@ -16,6 +16,40 @@
|
|||
"application/json"
|
||||
],
|
||||
"paths": {
|
||||
"/providers/Microsoft.RedHatOpenShift/listinstallopenshiftversions": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"InstallOpenShiftVersions"
|
||||
],
|
||||
"summary": "Lists all OpenShift versions available to install.",
|
||||
"description": "The operation returns the installable OpenShift versions as strings.",
|
||||
"operationId": "List_Installable_OpenShift_Versions",
|
||||
"parameters": [
|
||||
{
|
||||
"$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/InstallOpenShiftVersions"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Error response describing why the operation failed. If the resource doesn't exist, 404 (Not Found) is returned. If any of the input parameters is wrong, 400 (Bad Request) is returned.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/CloudError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-ms-examples": {
|
||||
"Lists all OpenShift versions available to install.": {
|
||||
"$ref": "./examples/List_Installable_OpenShift_Versions.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/providers/Microsoft.RedHatOpenShift/operations": {
|
||||
"get": {
|
||||
"tags": [
|
||||
|
@ -601,6 +635,9 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"InstallOpenShiftVersions": {
|
||||
"description": "InstallOpenShiftVersions represents a List of OpenShift installable versions."
|
||||
},
|
||||
"MasterProfile": {
|
||||
"description": "MasterProfile represents a master profile.",
|
||||
"type": "object",
|
||||
|
@ -769,6 +806,10 @@
|
|||
"description": "The cluster properties.",
|
||||
"x-ms-client-flatten": true
|
||||
},
|
||||
"installVersion": {
|
||||
"description": "The cluster install version.",
|
||||
"type": "string"
|
||||
},
|
||||
"systemData": {
|
||||
"$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/systemData",
|
||||
"description": "The system meta data relating to this resource.",
|
||||
|
|
Загрузка…
Ссылка в новой задаче