diff --git a/services/preview/confluent/mgmt/2021-03-01-preview/confluent/CHANGELOG.md b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/CHANGELOG.md new file mode 100644 index 000000000000..1abce7ec749c --- /dev/null +++ b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/CHANGELOG.md @@ -0,0 +1,5 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/a71245db9eb5b27e3d95f266422c65be4df8789e/specification/confluent/resource-manager/readme.md tag: `package-2021-03-01-preview` + +Code generator + + diff --git a/services/preview/confluent/mgmt/2021-03-01-preview/confluent/client.go b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/client.go new file mode 100644 index 000000000000..4cccbf448665 --- /dev/null +++ b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/client.go @@ -0,0 +1,41 @@ +// Package confluent implements the Azure ARM Confluent service API version 2021-03-01-preview. +// +// +package confluent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Confluent + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Confluent. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient 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 NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/confluent/mgmt/2021-03-01-preview/confluent/confluentapi/interfaces.go b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/confluentapi/interfaces.go new file mode 100644 index 000000000000..f8bc94b1a0cd --- /dev/null +++ b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/confluentapi/interfaces.go @@ -0,0 +1,43 @@ +package confluentapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/confluent/mgmt/2021-03-01-preview/confluent" +) + +// MarketplaceAgreementsClientAPI contains the set of methods on the MarketplaceAgreementsClient type. +type MarketplaceAgreementsClientAPI interface { + Create(ctx context.Context, body *confluent.AgreementResource) (result confluent.AgreementResource, err error) + List(ctx context.Context) (result confluent.AgreementResourceListResponsePage, err error) + ListComplete(ctx context.Context) (result confluent.AgreementResourceListResponseIterator, err error) +} + +var _ MarketplaceAgreementsClientAPI = (*confluent.MarketplaceAgreementsClient)(nil) + +// OrganizationOperationsClientAPI contains the set of methods on the OrganizationOperationsClient type. +type OrganizationOperationsClientAPI interface { + List(ctx context.Context) (result confluent.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result confluent.OperationListResultIterator, err error) +} + +var _ OrganizationOperationsClientAPI = (*confluent.OrganizationOperationsClient)(nil) + +// OrganizationClientAPI contains the set of methods on the OrganizationClient type. +type OrganizationClientAPI interface { + Create(ctx context.Context, resourceGroupName string, organizationName string, body *confluent.OrganizationResource) (result confluent.OrganizationCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, organizationName string) (result confluent.OrganizationDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, organizationName string) (result confluent.OrganizationResource, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result confluent.OrganizationResourceListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result confluent.OrganizationResourceListResultIterator, err error) + ListBySubscription(ctx context.Context) (result confluent.OrganizationResourceListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result confluent.OrganizationResourceListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, organizationName string, body *confluent.OrganizationResourceUpdate) (result confluent.OrganizationResource, err error) +} + +var _ OrganizationClientAPI = (*confluent.OrganizationClient)(nil) diff --git a/services/preview/confluent/mgmt/2021-03-01-preview/confluent/enums.go b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/enums.go new file mode 100644 index 000000000000..e1d500b1276f --- /dev/null +++ b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/enums.go @@ -0,0 +1,86 @@ +package confluent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// ProvisionState enumerates the values for provision state. +type ProvisionState string + +const ( + // Accepted ... + Accepted ProvisionState = "Accepted" + // Canceled ... + Canceled ProvisionState = "Canceled" + // Creating ... + Creating ProvisionState = "Creating" + // Deleted ... + Deleted ProvisionState = "Deleted" + // Deleting ... + Deleting ProvisionState = "Deleting" + // Failed ... + Failed ProvisionState = "Failed" + // NotSpecified ... + NotSpecified ProvisionState = "NotSpecified" + // Succeeded ... + Succeeded ProvisionState = "Succeeded" + // Updating ... + Updating ProvisionState = "Updating" +) + +// PossibleProvisionStateValues returns an array of possible values for the ProvisionState const type. +func PossibleProvisionStateValues() []ProvisionState { + return []ProvisionState{Accepted, Canceled, Creating, Deleted, Deleting, Failed, NotSpecified, Succeeded, Updating} +} + +// SaaSOfferStatus enumerates the values for saa s offer status. +type SaaSOfferStatus string + +const ( + // SaaSOfferStatusFailed ... + SaaSOfferStatusFailed SaaSOfferStatus = "Failed" + // SaaSOfferStatusInProgress ... + SaaSOfferStatusInProgress SaaSOfferStatus = "InProgress" + // SaaSOfferStatusPendingFulfillmentStart ... + SaaSOfferStatusPendingFulfillmentStart SaaSOfferStatus = "PendingFulfillmentStart" + // SaaSOfferStatusReinstated ... + SaaSOfferStatusReinstated SaaSOfferStatus = "Reinstated" + // SaaSOfferStatusStarted ... + SaaSOfferStatusStarted SaaSOfferStatus = "Started" + // SaaSOfferStatusSubscribed ... + SaaSOfferStatusSubscribed SaaSOfferStatus = "Subscribed" + // SaaSOfferStatusSucceeded ... + SaaSOfferStatusSucceeded SaaSOfferStatus = "Succeeded" + // SaaSOfferStatusSuspended ... + SaaSOfferStatusSuspended SaaSOfferStatus = "Suspended" + // SaaSOfferStatusUnsubscribed ... + SaaSOfferStatusUnsubscribed SaaSOfferStatus = "Unsubscribed" + // SaaSOfferStatusUpdating ... + SaaSOfferStatusUpdating SaaSOfferStatus = "Updating" +) + +// PossibleSaaSOfferStatusValues returns an array of possible values for the SaaSOfferStatus const type. +func PossibleSaaSOfferStatusValues() []SaaSOfferStatus { + return []SaaSOfferStatus{SaaSOfferStatusFailed, SaaSOfferStatusInProgress, SaaSOfferStatusPendingFulfillmentStart, SaaSOfferStatusReinstated, SaaSOfferStatusStarted, SaaSOfferStatusSubscribed, SaaSOfferStatusSucceeded, SaaSOfferStatusSuspended, SaaSOfferStatusUnsubscribed, SaaSOfferStatusUpdating} +} diff --git a/services/preview/confluent/mgmt/2021-03-01-preview/confluent/marketplaceagreements.go b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/marketplaceagreements.go new file mode 100644 index 000000000000..4be324da0c59 --- /dev/null +++ b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/marketplaceagreements.go @@ -0,0 +1,227 @@ +package confluent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MarketplaceAgreementsClient is the client for the MarketplaceAgreements methods of the Confluent service. +type MarketplaceAgreementsClient struct { + BaseClient +} + +// NewMarketplaceAgreementsClient creates an instance of the MarketplaceAgreementsClient client. +func NewMarketplaceAgreementsClient(subscriptionID string) MarketplaceAgreementsClient { + return NewMarketplaceAgreementsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMarketplaceAgreementsClientWithBaseURI creates an instance of the MarketplaceAgreementsClient 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 NewMarketplaceAgreementsClientWithBaseURI(baseURI string, subscriptionID string) MarketplaceAgreementsClient { + return MarketplaceAgreementsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create sends the create request. +// Parameters: +// body - confluent Marketplace Agreement resource +func (client MarketplaceAgreementsClient) Create(ctx context.Context, body *AgreementResource) (result AgreementResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MarketplaceAgreementsClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, body) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.MarketplaceAgreementsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "confluent.MarketplaceAgreementsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.MarketplaceAgreementsClient", "Create", resp, "Failure responding to request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client MarketplaceAgreementsClient) CreatePreparer(ctx context.Context, body *AgreementResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + body.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Confluent/agreements/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client MarketplaceAgreementsClient) CreateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client MarketplaceAgreementsClient) CreateResponder(resp *http.Response) (result AgreementResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +func (client MarketplaceAgreementsClient) List(ctx context.Context) (result AgreementResourceListResponsePage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MarketplaceAgreementsClient.List") + defer func() { + sc := -1 + if result.arlr.Response.Response != nil { + sc = result.arlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.MarketplaceAgreementsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.arlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "confluent.MarketplaceAgreementsClient", "List", resp, "Failure sending request") + return + } + + result.arlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.MarketplaceAgreementsClient", "List", resp, "Failure responding to request") + return + } + if result.arlr.hasNextLink() && result.arlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client MarketplaceAgreementsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Confluent/agreements", 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 MarketplaceAgreementsClient) 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 MarketplaceAgreementsClient) ListResponder(resp *http.Response) (result AgreementResourceListResponse, 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 MarketplaceAgreementsClient) listNextResults(ctx context.Context, lastResults AgreementResourceListResponse) (result AgreementResourceListResponse, err error) { + req, err := lastResults.agreementResourceListResponsePreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "confluent.MarketplaceAgreementsClient", "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, "confluent.MarketplaceAgreementsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.MarketplaceAgreementsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client MarketplaceAgreementsClient) ListComplete(ctx context.Context) (result AgreementResourceListResponseIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MarketplaceAgreementsClient.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 +} diff --git a/services/preview/confluent/mgmt/2021-03-01-preview/confluent/models.go b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/models.go new file mode 100644 index 000000000000..bfa50e05dd9b --- /dev/null +++ b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/models.go @@ -0,0 +1,918 @@ +package confluent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/confluent/mgmt/2021-03-01-preview/confluent" + +// AgreementProperties terms properties for Marketplace and Confluent. +type AgreementProperties struct { + // Publisher - Publisher identifier string. + Publisher *string `json:"publisher,omitempty"` + // Product - Product identifier string. + Product *string `json:"product,omitempty"` + // Plan - Plan identifier string. + Plan *string `json:"plan,omitempty"` + // LicenseTextLink - Link to HTML with Microsoft and Publisher terms. + LicenseTextLink *string `json:"licenseTextLink,omitempty"` + // PrivacyPolicyLink - Link to the privacy policy of the publisher. + PrivacyPolicyLink *string `json:"privacyPolicyLink,omitempty"` + // RetrieveDatetime - Date and time in UTC of when the terms were accepted. This is empty if Accepted is false. + RetrieveDatetime *date.Time `json:"retrieveDatetime,omitempty"` + // Signature - Terms signature. + Signature *string `json:"signature,omitempty"` + // Accepted - If any version of the terms have been accepted, otherwise false. + Accepted *bool `json:"accepted,omitempty"` +} + +// AgreementResource agreement Terms definition +type AgreementResource struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The ARM id of the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the agreement. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the agreement. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty"` + // AgreementProperties - Represents the properties of the resource. + *AgreementProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AgreementResource. +func (ar AgreementResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ar.AgreementProperties != nil { + objectMap["properties"] = ar.AgreementProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AgreementResource struct. +func (ar *AgreementResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ar.Type = &typeVar + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + ar.SystemData = &systemData + } + case "properties": + if v != nil { + var agreementProperties AgreementProperties + err = json.Unmarshal(*v, &agreementProperties) + if err != nil { + return err + } + ar.AgreementProperties = &agreementProperties + } + } + } + + return nil +} + +// AgreementResourceListResponse response of a list operation. +type AgreementResourceListResponse struct { + autorest.Response `json:"-"` + // Value - Results of a list operation. + Value *[]AgreementResource `json:"value,omitempty"` + // NextLink - Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// AgreementResourceListResponseIterator provides access to a complete listing of AgreementResource values. +type AgreementResourceListResponseIterator struct { + i int + page AgreementResourceListResponsePage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AgreementResourceListResponseIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AgreementResourceListResponseIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AgreementResourceListResponseIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AgreementResourceListResponseIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AgreementResourceListResponseIterator) Response() AgreementResourceListResponse { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AgreementResourceListResponseIterator) Value() AgreementResource { + if !iter.page.NotDone() { + return AgreementResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AgreementResourceListResponseIterator type. +func NewAgreementResourceListResponseIterator(page AgreementResourceListResponsePage) AgreementResourceListResponseIterator { + return AgreementResourceListResponseIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (arlr AgreementResourceListResponse) IsEmpty() bool { + return arlr.Value == nil || len(*arlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (arlr AgreementResourceListResponse) hasNextLink() bool { + return arlr.NextLink != nil && len(*arlr.NextLink) != 0 +} + +// agreementResourceListResponsePreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (arlr AgreementResourceListResponse) agreementResourceListResponsePreparer(ctx context.Context) (*http.Request, error) { + if !arlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(arlr.NextLink))) +} + +// AgreementResourceListResponsePage contains a page of AgreementResource values. +type AgreementResourceListResponsePage struct { + fn func(context.Context, AgreementResourceListResponse) (AgreementResourceListResponse, error) + arlr AgreementResourceListResponse +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AgreementResourceListResponsePage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AgreementResourceListResponsePage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.arlr) + if err != nil { + return err + } + page.arlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AgreementResourceListResponsePage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AgreementResourceListResponsePage) NotDone() bool { + return !page.arlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AgreementResourceListResponsePage) Response() AgreementResourceListResponse { + return page.arlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AgreementResourceListResponsePage) Values() []AgreementResource { + if page.arlr.IsEmpty() { + return nil + } + return *page.arlr.Value +} + +// Creates a new instance of the AgreementResourceListResponsePage type. +func NewAgreementResourceListResponsePage(cur AgreementResourceListResponse, getNextPage func(context.Context, AgreementResourceListResponse) (AgreementResourceListResponse, error)) AgreementResourceListResponsePage { + return AgreementResourceListResponsePage{ + fn: getNextPage, + arlr: cur, + } +} + +// ErrorResponseBody response body of Error +type ErrorResponseBody struct { + // Code - READ-ONLY; Error code + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Error message + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; Error target + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; Error detail + Details *[]ErrorResponseBody `json:"details,omitempty"` +} + +// OfferDetail confluent Offer detail +type OfferDetail struct { + // PublisherID - Publisher Id + PublisherID *string `json:"publisherId,omitempty"` + // ID - Offer Id + ID *string `json:"id,omitempty"` + // PlanID - Offer Plan Id + PlanID *string `json:"planId,omitempty"` + // PlanName - Offer Plan Name + PlanName *string `json:"planName,omitempty"` + // TermUnit - Offer Plan Term unit + TermUnit *string `json:"termUnit,omitempty"` + // Status - SaaS Offer Status. Possible values include: 'SaaSOfferStatusStarted', 'SaaSOfferStatusPendingFulfillmentStart', 'SaaSOfferStatusInProgress', 'SaaSOfferStatusSubscribed', 'SaaSOfferStatusSuspended', 'SaaSOfferStatusReinstated', 'SaaSOfferStatusSucceeded', 'SaaSOfferStatusFailed', 'SaaSOfferStatusUnsubscribed', 'SaaSOfferStatusUpdating' + Status SaaSOfferStatus `json:"status,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Confluent + Provider *string `json:"provider,omitempty"` + // Resource - Type on which the operation is performed, e.g., 'clusters'. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type, e.g., read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + // Description - Description of the operation, e.g., 'Write confluent'. + Description *string `json:"description,omitempty"` +} + +// OperationListResult result of GET request to list Confluent operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of Confluent operations supported by the Microsoft.Confluent provider. + Value *[]OperationResult `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of OperationResult values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() OperationResult { + if !iter.page.NotDone() { + return OperationResult{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of OperationResult values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []OperationResult { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// OperationResult an Confluent REST API operation. +type OperationResult struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` + // IsDataAction - Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` +} + +// OrganizationCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OrganizationCreateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(OrganizationClient) (OrganizationResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *OrganizationCreateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for OrganizationCreateFuture.Result. +func (future *OrganizationCreateFuture) result(client OrganizationClient) (or OrganizationResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("confluent.OrganizationCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if or.Response.Response, err = future.GetResult(sender); err == nil && or.Response.Response.StatusCode != http.StatusNoContent { + or, err = client.CreateResponder(or.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationCreateFuture", "Result", or.Response.Response, "Failure responding to request") + } + } + return +} + +// OrganizationDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OrganizationDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(OrganizationClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *OrganizationDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for OrganizationDeleteFuture.Result. +func (future *OrganizationDeleteFuture) result(client OrganizationClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("confluent.OrganizationDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// OrganizationResource organization resource. +type OrganizationResource struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The ARM id of the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty"` + // OrganizationResourceProperties - Organization resource properties + *OrganizationResourceProperties `json:"properties,omitempty"` + // Tags - Organization resource tags + Tags map[string]*string `json:"tags"` + // Location - Location of Organization resource + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for OrganizationResource. +func (or OrganizationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if or.OrganizationResourceProperties != nil { + objectMap["properties"] = or.OrganizationResourceProperties + } + if or.Tags != nil { + objectMap["tags"] = or.Tags + } + if or.Location != nil { + objectMap["location"] = or.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OrganizationResource struct. +func (or *OrganizationResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + or.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + or.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + or.Type = &typeVar + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + or.SystemData = &systemData + } + case "properties": + if v != nil { + var organizationResourceProperties OrganizationResourceProperties + err = json.Unmarshal(*v, &organizationResourceProperties) + if err != nil { + return err + } + or.OrganizationResourceProperties = &organizationResourceProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + or.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + or.Location = &location + } + } + } + + return nil +} + +// OrganizationResourceListResult the response of a list operation. +type OrganizationResourceListResult struct { + autorest.Response `json:"-"` + // Value - Result of a list operation. + Value *[]OrganizationResource `json:"value,omitempty"` + // NextLink - Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OrganizationResourceListResultIterator provides access to a complete listing of OrganizationResource +// values. +type OrganizationResourceListResultIterator struct { + i int + page OrganizationResourceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OrganizationResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationResourceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OrganizationResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OrganizationResourceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OrganizationResourceListResultIterator) Response() OrganizationResourceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OrganizationResourceListResultIterator) Value() OrganizationResource { + if !iter.page.NotDone() { + return OrganizationResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OrganizationResourceListResultIterator type. +func NewOrganizationResourceListResultIterator(page OrganizationResourceListResultPage) OrganizationResourceListResultIterator { + return OrganizationResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (orlr OrganizationResourceListResult) IsEmpty() bool { + return orlr.Value == nil || len(*orlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (orlr OrganizationResourceListResult) hasNextLink() bool { + return orlr.NextLink != nil && len(*orlr.NextLink) != 0 +} + +// organizationResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (orlr OrganizationResourceListResult) organizationResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !orlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(orlr.NextLink))) +} + +// OrganizationResourceListResultPage contains a page of OrganizationResource values. +type OrganizationResourceListResultPage struct { + fn func(context.Context, OrganizationResourceListResult) (OrganizationResourceListResult, error) + orlr OrganizationResourceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OrganizationResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationResourceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.orlr) + if err != nil { + return err + } + page.orlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OrganizationResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OrganizationResourceListResultPage) NotDone() bool { + return !page.orlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OrganizationResourceListResultPage) Response() OrganizationResourceListResult { + return page.orlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OrganizationResourceListResultPage) Values() []OrganizationResource { + if page.orlr.IsEmpty() { + return nil + } + return *page.orlr.Value +} + +// Creates a new instance of the OrganizationResourceListResultPage type. +func NewOrganizationResourceListResultPage(cur OrganizationResourceListResult, getNextPage func(context.Context, OrganizationResourceListResult) (OrganizationResourceListResult, error)) OrganizationResourceListResultPage { + return OrganizationResourceListResultPage{ + fn: getNextPage, + orlr: cur, + } +} + +// OrganizationResourceProperties organization resource property +type OrganizationResourceProperties struct { + // CreatedTime - READ-ONLY; The creation time of the resource. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // ProvisioningState - READ-ONLY; Provision states for confluent RP. Possible values include: 'Accepted', 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'NotSpecified' + ProvisioningState ProvisionState `json:"provisioningState,omitempty"` + // OrganizationID - READ-ONLY; Id of the Confluent organization. + OrganizationID *string `json:"organizationId,omitempty"` + // SsoURL - READ-ONLY; SSO url for the Confluent organization. + SsoURL *string `json:"ssoUrl,omitempty"` + // OfferDetail - Confluent offer detail + OfferDetail *OfferDetail `json:"offerDetail,omitempty"` + // UserDetail - Subscriber detail + UserDetail *UserDetail `json:"userDetail,omitempty"` +} + +// MarshalJSON is the custom marshaler for OrganizationResourceProperties. +func (orp OrganizationResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if orp.OfferDetail != nil { + objectMap["offerDetail"] = orp.OfferDetail + } + if orp.UserDetail != nil { + objectMap["userDetail"] = orp.UserDetail + } + return json.Marshal(objectMap) +} + +// OrganizationResourceUpdate organization Resource update +type OrganizationResourceUpdate struct { + // Tags - ARM resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for OrganizationResourceUpdate. +func (oru OrganizationResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if oru.Tags != nil { + objectMap["tags"] = oru.Tags + } + return json.Marshal(objectMap) +} + +// ResourceProviderDefaultErrorResponse default error response for resource provider +type ResourceProviderDefaultErrorResponse struct { + // Error - READ-ONLY; Response body of Error + Error *ErrorResponseBody `json:"error,omitempty"` +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// UserDetail subscriber detail +type UserDetail struct { + // FirstName - First name + FirstName *string `json:"firstName,omitempty"` + // LastName - Last name + LastName *string `json:"lastName,omitempty"` + // EmailAddress - Email address + EmailAddress *string `json:"emailAddress,omitempty"` +} diff --git a/services/preview/confluent/mgmt/2021-03-01-preview/confluent/organization.go b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/organization.go new file mode 100644 index 000000000000..3afc77054991 --- /dev/null +++ b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/organization.go @@ -0,0 +1,613 @@ +package confluent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OrganizationClient is the client for the Organization methods of the Confluent service. +type OrganizationClient struct { + BaseClient +} + +// NewOrganizationClient creates an instance of the OrganizationClient client. +func NewOrganizationClient(subscriptionID string) OrganizationClient { + return NewOrganizationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOrganizationClientWithBaseURI creates an instance of the OrganizationClient 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 NewOrganizationClientWithBaseURI(baseURI string, subscriptionID string) OrganizationClient { + return OrganizationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create sends the create request. +// Parameters: +// resourceGroupName - resource group name +// organizationName - organization resource name +// body - organization resource model +func (client OrganizationClient) Create(ctx context.Context, resourceGroupName string, organizationName string, body *OrganizationResource) (result OrganizationCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationClient.Create") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.OfferDetail", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.OfferDetail.PublisherID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.OfferDetail.PublisherID", Name: validation.MaxLength, Rule: 50, Chain: nil}}}, + {Target: "body.OrganizationResourceProperties.OfferDetail.ID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.OfferDetail.ID", Name: validation.MaxLength, Rule: 50, Chain: nil}}}, + {Target: "body.OrganizationResourceProperties.OfferDetail.PlanID", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.OfferDetail.PlanID", Name: validation.MaxLength, Rule: 50, Chain: nil}}}, + {Target: "body.OrganizationResourceProperties.OfferDetail.PlanName", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.OfferDetail.PlanName", Name: validation.MaxLength, Rule: 50, Chain: nil}}}, + {Target: "body.OrganizationResourceProperties.OfferDetail.TermUnit", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.OfferDetail.TermUnit", Name: validation.MaxLength, Rule: 25, Chain: nil}}}, + }}, + {Target: "body.OrganizationResourceProperties.UserDetail", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.UserDetail.FirstName", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.UserDetail.FirstName", Name: validation.MaxLength, Rule: 50, Chain: nil}}}, + {Target: "body.OrganizationResourceProperties.UserDetail.LastName", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.UserDetail.LastName", Name: validation.MaxLength, Rule: 50, Chain: nil}}}, + {Target: "body.OrganizationResourceProperties.UserDetail.EmailAddress", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.OrganizationResourceProperties.UserDetail.EmailAddress", Name: validation.Pattern, Rule: `^\S+@\S+\.\S+$`, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("confluent.OrganizationClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, organizationName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "Create", nil, "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client OrganizationClient) CreatePreparer(ctx context.Context, resourceGroupName string, organizationName string, body *OrganizationResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "organizationName": autorest.Encode("path", organizationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + body.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client OrganizationClient) CreateSender(req *http.Request) (future OrganizationCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client OrganizationClient) CreateResponder(resp *http.Response) (result OrganizationResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete sends the delete request. +// Parameters: +// resourceGroupName - resource group name +// organizationName - organization resource name +func (client OrganizationClient) Delete(ctx context.Context, resourceGroupName string, organizationName string) (result OrganizationDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, organizationName) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client OrganizationClient) DeletePreparer(ctx context.Context, resourceGroupName string, organizationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "organizationName": autorest.Encode("path", organizationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client OrganizationClient) DeleteSender(req *http.Request) (future OrganizationDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client OrganizationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - resource group name +// organizationName - organization resource name +func (client OrganizationClient) Get(ctx context.Context, resourceGroupName string, organizationName string) (result OrganizationResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, organizationName) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client OrganizationClient) GetPreparer(ctx context.Context, resourceGroupName string, organizationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "organizationName": autorest.Encode("path", organizationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client OrganizationClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OrganizationClient) GetResponder(resp *http.Response) (result OrganizationResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup sends the list by resource group request. +// Parameters: +// resourceGroupName - resource group name +func (client OrganizationClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result OrganizationResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.orlr.Response.Response != nil { + sc = result.orlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.orlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.orlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.orlr.hasNextLink() && result.orlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client OrganizationClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client OrganizationClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client OrganizationClient) ListByResourceGroupResponder(resp *http.Response) (result OrganizationResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client OrganizationClient) listByResourceGroupNextResults(ctx context.Context, lastResults OrganizationResourceListResult) (result OrganizationResourceListResult, err error) { + req, err := lastResults.organizationResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "confluent.OrganizationClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "confluent.OrganizationClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client OrganizationClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result OrganizationResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationClient.ListByResourceGroup") + 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.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription sends the list by subscription request. +func (client OrganizationClient) ListBySubscription(ctx context.Context) (result OrganizationResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationClient.ListBySubscription") + defer func() { + sc := -1 + if result.orlr.Response.Response != nil { + sc = result.orlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.orlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.orlr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.orlr.hasNextLink() && result.orlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client OrganizationClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Confluent/organizations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client OrganizationClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client OrganizationClient) ListBySubscriptionResponder(resp *http.Response) (result OrganizationResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client OrganizationClient) listBySubscriptionNextResults(ctx context.Context, lastResults OrganizationResourceListResult) (result OrganizationResourceListResult, err error) { + req, err := lastResults.organizationResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "confluent.OrganizationClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "confluent.OrganizationClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client OrganizationClient) ListBySubscriptionComplete(ctx context.Context) (result OrganizationResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationClient.ListBySubscription") + 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.ListBySubscription(ctx) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - resource group name +// organizationName - organization resource name +// body - updated Organization resource +func (client OrganizationClient) Update(ctx context.Context, resourceGroupName string, organizationName string, body *OrganizationResourceUpdate) (result OrganizationResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, organizationName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client OrganizationClient) UpdatePreparer(ctx context.Context, resourceGroupName string, organizationName string, body *OrganizationResourceUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "organizationName": autorest.Encode("path", organizationName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Confluent/organizations/{organizationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client OrganizationClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client OrganizationClient) UpdateResponder(resp *http.Response) (result OrganizationResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/confluent/mgmt/2021-03-01-preview/confluent/organizationoperations.go b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/organizationoperations.go new file mode 100644 index 000000000000..213e3846f865 --- /dev/null +++ b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/organizationoperations.go @@ -0,0 +1,141 @@ +package confluent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OrganizationOperationsClient is the client for the OrganizationOperations methods of the Confluent service. +type OrganizationOperationsClient struct { + BaseClient +} + +// NewOrganizationOperationsClient creates an instance of the OrganizationOperationsClient client. +func NewOrganizationOperationsClient(subscriptionID string) OrganizationOperationsClient { + return NewOrganizationOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOrganizationOperationsClientWithBaseURI creates an instance of the OrganizationOperationsClient 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 NewOrganizationOperationsClientWithBaseURI(baseURI string, subscriptionID string) OrganizationOperationsClient { + return OrganizationOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List sends the list request. +func (client OrganizationOperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationOperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationOperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "confluent.OrganizationOperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationOperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OrganizationOperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-03-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Confluent/operations"), + 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 OrganizationOperationsClient) ListSender(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 +// closes the http.Response Body. +func (client OrganizationOperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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 OrganizationOperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "confluent.OrganizationOperationsClient", "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, "confluent.OrganizationOperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "confluent.OrganizationOperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OrganizationOperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OrganizationOperationsClient.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 +} diff --git a/services/preview/confluent/mgmt/2021-03-01-preview/confluent/version.go b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/version.go new file mode 100644 index 000000000000..7d2699ca225f --- /dev/null +++ b/services/preview/confluent/mgmt/2021-03-01-preview/confluent/version.go @@ -0,0 +1,19 @@ +package confluent + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " confluent/2021-03-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}