diff --git a/profiles/preview/apimanagement/mgmt/apimanagement/models.go b/profiles/preview/apimanagement/mgmt/apimanagement/models.go index 431efa467967..301c9adda38b 100644 --- a/profiles/preview/apimanagement/mgmt/apimanagement/models.go +++ b/profiles/preview/apimanagement/mgmt/apimanagement/models.go @@ -419,6 +419,7 @@ type CertificateCreateOrUpdateParameters = original.CertificateCreateOrUpdatePar type CertificateCreateOrUpdateProperties = original.CertificateCreateOrUpdateProperties type CertificateInformation = original.CertificateInformation type ConnectivityStatusContract = original.ConnectivityStatusContract +type CurrentUserIdentity = original.CurrentUserIdentity type DeployConfigurationParameters = original.DeployConfigurationParameters type DiagnosticCollection = original.DiagnosticCollection type DiagnosticCollectionIterator = original.DiagnosticCollectionIterator @@ -470,7 +471,10 @@ type IssueCommentCollectionPage = original.IssueCommentCollectionPage type IssueCommentContract = original.IssueCommentContract type IssueCommentContractProperties = original.IssueCommentContractProperties type IssueContract = original.IssueContract +type IssueContractBaseProperties = original.IssueContractBaseProperties type IssueContractProperties = original.IssueContractProperties +type IssueUpdateContract = original.IssueUpdateContract +type IssueUpdateContractProperties = original.IssueUpdateContractProperties type ListNetworkStatusContractByLocation = original.ListNetworkStatusContractByLocation type LoggerCollection = original.LoggerCollection type LoggerCollectionIterator = original.LoggerCollectionIterator diff --git a/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go b/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go index 540ad8538c19..2c3197aa26bd 100644 --- a/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go +++ b/profiles/preview/preview/apimanagement/mgmt/apimanagement/models.go @@ -430,6 +430,7 @@ type CertificateCreateOrUpdateParameters = original.CertificateCreateOrUpdatePar type CertificateCreateOrUpdateProperties = original.CertificateCreateOrUpdateProperties type CertificateInformation = original.CertificateInformation type ConnectivityStatusContract = original.ConnectivityStatusContract +type CurrentUserIdentity = original.CurrentUserIdentity type DeployConfigurationParameters = original.DeployConfigurationParameters type DiagnosticCollection = original.DiagnosticCollection type DiagnosticCollectionIterator = original.DiagnosticCollectionIterator @@ -482,7 +483,10 @@ type IssueCommentCollectionPage = original.IssueCommentCollectionPage type IssueCommentContract = original.IssueCommentContract type IssueCommentContractProperties = original.IssueCommentContractProperties type IssueContract = original.IssueContract +type IssueContractBaseProperties = original.IssueContractBaseProperties type IssueContractProperties = original.IssueContractProperties +type IssueUpdateContract = original.IssueUpdateContract +type IssueUpdateContractProperties = original.IssueUpdateContractProperties type ListNetworkStatusContractByLocation = original.ListNetworkStatusContractByLocation type LoggerCollection = original.LoggerCollection type LoggerCollectionIterator = original.LoggerCollectionIterator diff --git a/services/apimanagement/mgmt/2017-03-01/apimanagement/models.go b/services/apimanagement/mgmt/2017-03-01/apimanagement/models.go index d128ea1da24d..7c7045bdb7fe 100644 --- a/services/apimanagement/mgmt/2017-03-01/apimanagement/models.go +++ b/services/apimanagement/mgmt/2017-03-01/apimanagement/models.go @@ -2728,7 +2728,7 @@ type BackendReconnectProperties struct { type BackendServiceFabricClusterProperties struct { // ClientCertificatethumbprint - The client certificate thumbprint for the management endpoint. ClientCertificatethumbprint *string `json:"clientCertificatethumbprint,omitempty"` - // MaxPartitionResolutionRetries - Maximum number of retries while attempting resolve the parition. + // MaxPartitionResolutionRetries - Maximum number of retries while attempting resolve the partition. MaxPartitionResolutionRetries *int32 `json:"maxPartitionResolutionRetries,omitempty"` // ManagementEndpoints - The cluster management endpoint. ManagementEndpoints *[]string `json:"managementEndpoints,omitempty"` diff --git a/services/apimanagement/mgmt/2018-01-01/apimanagement/apiissue.go b/services/apimanagement/mgmt/2018-01-01/apimanagement/apiissue.go index 4a8154dfffc0..a021791d3313 100644 --- a/services/apimanagement/mgmt/2018-01-01/apimanagement/apiissue.go +++ b/services/apimanagement/mgmt/2018-01-01/apimanagement/apiissue.go @@ -595,3 +595,108 @@ func (client APIIssueClient) ListByServiceComplete(ctx context.Context, resource result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) return } + +// Update updates an existing issue for an API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// parameters - update parameters. +// ifMatch - eTag of the Issue Entity. ETag should match the current entity state from the header response of +// the GET request or it should be * for unconditional update. +func (client APIIssueClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueUpdateContract, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.Update") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client APIIssueClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueUpdateContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-01" + 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.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + 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 APIIssueClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client APIIssueClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/apimanagement/mgmt/2018-01-01/apimanagement/apimanagementapi/interfaces.go b/services/apimanagement/mgmt/2018-01-01/apimanagement/apimanagementapi/interfaces.go index 40beed733bd0..455582740838 100644 --- a/services/apimanagement/mgmt/2018-01-01/apimanagement/apimanagementapi/interfaces.go +++ b/services/apimanagement/mgmt/2018-01-01/apimanagement/apimanagementapi/interfaces.go @@ -161,6 +161,7 @@ type APIIssueClientAPI interface { Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string) (result apimanagement.IssueContract, err error) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string) (result autorest.Response, err error) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.IssueCollectionPage, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters apimanagement.IssueUpdateContract, ifMatch string) (result autorest.Response, err error) } var _ APIIssueClientAPI = (*apimanagement.APIIssueClient)(nil) @@ -602,6 +603,7 @@ type UserClientAPI interface { GenerateSsoURL(ctx context.Context, resourceGroupName string, serviceName string, UID string) (result apimanagement.GenerateSsoURLResult, err error) Get(ctx context.Context, resourceGroupName string, serviceName string, UID string) (result apimanagement.UserContract, err error) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, UID string) (result autorest.Response, err error) + GetIdentity(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.CurrentUserIdentity, err error) GetSharedAccessToken(ctx context.Context, resourceGroupName string, serviceName string, UID string, parameters apimanagement.UserTokenParameters) (result apimanagement.UserTokenResult, err error) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.UserCollectionPage, err error) Update(ctx context.Context, resourceGroupName string, serviceName string, UID string, parameters apimanagement.UserUpdateParameters, ifMatch string) (result autorest.Response, err error) diff --git a/services/apimanagement/mgmt/2018-01-01/apimanagement/models.go b/services/apimanagement/mgmt/2018-01-01/apimanagement/models.go index 7b354b09db3d..44664c98b672 100644 --- a/services/apimanagement/mgmt/2018-01-01/apimanagement/models.go +++ b/services/apimanagement/mgmt/2018-01-01/apimanagement/models.go @@ -2796,7 +2796,7 @@ type BackendReconnectProperties struct { type BackendServiceFabricClusterProperties struct { // ClientCertificatethumbprint - The client certificate thumbprint for the management endpoint. ClientCertificatethumbprint *string `json:"clientCertificatethumbprint,omitempty"` - // MaxPartitionResolutionRetries - Maximum number of retries while attempting resolve the parition. + // MaxPartitionResolutionRetries - Maximum number of retries while attempting resolve the partition. MaxPartitionResolutionRetries *int32 `json:"maxPartitionResolutionRetries,omitempty"` // ManagementEndpoints - The cluster management endpoint. ManagementEndpoints *[]string `json:"managementEndpoints,omitempty"` @@ -3198,6 +3198,13 @@ type ConnectivityStatusContract struct { LastStatusChange *date.Time `json:"lastStatusChange,omitempty"` } +// CurrentUserIdentity ... +type CurrentUserIdentity struct { + autorest.Response `json:"-"` + // ID - API Management service user id. + ID *string `json:"id,omitempty"` +} + // DeployConfigurationParameters parameters supplied to the Deploy Configuration operation. type DeployConfigurationParameters struct { // Branch - The name of the Git branch from which the configuration is to be deployed to the configuration database. @@ -5217,18 +5224,83 @@ func (ic *IssueContract) UnmarshalJSON(body []byte) error { return nil } +// IssueContractBaseProperties issue contract Base Properties. +type IssueContractBaseProperties struct { + // CreatedDate - Date and time when the issue was created. + CreatedDate *date.Time `json:"createdDate,omitempty"` + // State - Status of the issue. Possible values include: 'Proposed', 'Open', 'Removed', 'Resolved', 'Closed' + State State `json:"state,omitempty"` + // APIID - A resource identifier for the API the issue was created for. + APIID *string `json:"apiId,omitempty"` +} + // IssueContractProperties issue contract Properties. type IssueContractProperties struct { // Title - The issue title. Title *string `json:"title,omitempty"` // Description - Text describing the issue. Description *string `json:"description,omitempty"` + // UserID - A resource identifier for the user created the issue. + UserID *string `json:"userId,omitempty"` // CreatedDate - Date and time when the issue was created. CreatedDate *date.Time `json:"createdDate,omitempty"` // State - Status of the issue. Possible values include: 'Proposed', 'Open', 'Removed', 'Resolved', 'Closed' State State `json:"state,omitempty"` + // APIID - A resource identifier for the API the issue was created for. + APIID *string `json:"apiId,omitempty"` +} + +// IssueUpdateContract issue update Parameters. +type IssueUpdateContract struct { + // IssueUpdateContractProperties - Issue entity Update contract properties. + *IssueUpdateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IssueUpdateContract. +func (iuc IssueUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if iuc.IssueUpdateContractProperties != nil { + objectMap["properties"] = iuc.IssueUpdateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IssueUpdateContract struct. +func (iuc *IssueUpdateContract) 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 "properties": + if v != nil { + var issueUpdateContractProperties IssueUpdateContractProperties + err = json.Unmarshal(*v, &issueUpdateContractProperties) + if err != nil { + return err + } + iuc.IssueUpdateContractProperties = &issueUpdateContractProperties + } + } + } + + return nil +} + +// IssueUpdateContractProperties issue contract Update Properties. +type IssueUpdateContractProperties struct { + // Title - The issue title. + Title *string `json:"title,omitempty"` + // Description - Text describing the issue. + Description *string `json:"description,omitempty"` // UserID - A resource identifier for the user created the issue. UserID *string `json:"userId,omitempty"` + // CreatedDate - Date and time when the issue was created. + CreatedDate *date.Time `json:"createdDate,omitempty"` + // State - Status of the issue. Possible values include: 'Proposed', 'Open', 'Removed', 'Resolved', 'Closed' + State State `json:"state,omitempty"` // APIID - A resource identifier for the API the issue was created for. APIID *string `json:"apiId,omitempty"` } diff --git a/services/apimanagement/mgmt/2018-01-01/apimanagement/user.go b/services/apimanagement/mgmt/2018-01-01/apimanagement/user.go index 3f5dd69dc040..1364af2f9fde 100644 --- a/services/apimanagement/mgmt/2018-01-01/apimanagement/user.go +++ b/services/apimanagement/mgmt/2018-01-01/apimanagement/user.go @@ -529,6 +529,91 @@ func (client UserClient) GetEntityTagResponder(resp *http.Response) (result auto return } +// GetIdentity returns calling user identity information. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client UserClient) GetIdentity(ctx context.Context, resourceGroupName string, serviceName string) (result CurrentUserIdentity, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.GetIdentity") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.UserClient", "GetIdentity", err.Error()) + } + + req, err := client.GetIdentityPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetIdentity", nil, "Failure preparing request") + return + } + + resp, err := client.GetIdentitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetIdentity", resp, "Failure sending request") + return + } + + result, err = client.GetIdentityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetIdentity", resp, "Failure responding to request") + } + + return +} + +// GetIdentityPreparer prepares the GetIdentity request. +func (client UserClient) GetIdentityPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identity", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetIdentitySender sends the GetIdentity request. The method will close the +// http.Response Body if it receives an error. +func (client UserClient) GetIdentitySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetIdentityResponder handles the response to the GetIdentity request. The method always +// closes the http.Response Body. +func (client UserClient) GetIdentityResponder(resp *http.Response) (result CurrentUserIdentity, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // GetSharedAccessToken gets the Shared Access Authorization Token for the User. // Parameters: // resourceGroupName - the name of the resource group. diff --git a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/apiissue.go b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/apiissue.go index 2d7dcd9a3ca8..8aacdb800a37 100644 --- a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/apiissue.go +++ b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/apiissue.go @@ -595,3 +595,108 @@ func (client APIIssueClient) ListByServiceComplete(ctx context.Context, resource result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) return } + +// Update updates an existing issue for an API. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +// apiid - API identifier. Must be unique in the current API Management service instance. +// issueID - issue identifier. Must be unique in the current API Management service instance. +// parameters - update parameters. +// ifMatch - eTag of the Issue Entity. ETag should match the current entity state from the header response of +// the GET request or it should be * for unconditional update. +func (client APIIssueClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueUpdateContract, ifMatch string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIIssueClient.Update") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, + {TargetValue: apiid, + Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "apiid", Name: validation.Pattern, Rule: `(^[\w]+$)|(^[\w][\w\-]+[\w]$)`, Chain: nil}}}, + {TargetValue: issueID, + Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, + {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.APIIssueClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, apiid, issueID, parameters, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.APIIssueClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client APIIssueClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters IssueUpdateContract, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "apiId": autorest.Encode("path", apiid), + "issueId": autorest.Encode("path", issueID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + 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 APIIssueClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client APIIssueClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/apimanagementapi/interfaces.go b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/apimanagementapi/interfaces.go index 1a6819c4234f..33f2b230a42e 100644 --- a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/apimanagementapi/interfaces.go +++ b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/apimanagementapi/interfaces.go @@ -151,6 +151,7 @@ type APIIssueClientAPI interface { Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string) (result apimanagement.IssueContract, err error) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string) (result autorest.Response, err error) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result apimanagement.IssueCollectionPage, err error) + Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, parameters apimanagement.IssueUpdateContract, ifMatch string) (result autorest.Response, err error) } var _ APIIssueClientAPI = (*apimanagement.APIIssueClient)(nil) @@ -583,6 +584,7 @@ type UserClientAPI interface { GenerateSsoURL(ctx context.Context, resourceGroupName string, serviceName string, UID string) (result apimanagement.GenerateSsoURLResult, err error) Get(ctx context.Context, resourceGroupName string, serviceName string, UID string) (result apimanagement.UserContract, err error) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, UID string) (result autorest.Response, err error) + GetIdentity(ctx context.Context, resourceGroupName string, serviceName string) (result apimanagement.CurrentUserIdentity, err error) GetSharedAccessToken(ctx context.Context, resourceGroupName string, serviceName string, UID string, parameters apimanagement.UserTokenParameters) (result apimanagement.UserTokenResult, err error) ListByService(ctx context.Context, resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result apimanagement.UserCollectionPage, err error) Update(ctx context.Context, resourceGroupName string, serviceName string, UID string, parameters apimanagement.UserUpdateParameters, ifMatch string) (result autorest.Response, err error) diff --git a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go index 736018358c13..bd6bfe9d7566 100644 --- a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go +++ b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/models.go @@ -2824,7 +2824,7 @@ func (brc *BackendReconnectContract) UnmarshalJSON(body []byte) error { // BackendReconnectProperties properties to control reconnect requests. type BackendReconnectProperties struct { - // After - Duration in ISO8601 format after which reconnect will be initiated. Minimum duration of the Reconect is PT2M. + // After - Duration in ISO8601 format after which reconnect will be initiated. Minimum duration of the Reconnect is PT2M. After *string `json:"after,omitempty"` } @@ -2832,7 +2832,7 @@ type BackendReconnectProperties struct { type BackendServiceFabricClusterProperties struct { // ClientCertificatethumbprint - The client certificate thumbprint for the management endpoint. ClientCertificatethumbprint *string `json:"clientCertificatethumbprint,omitempty"` - // MaxPartitionResolutionRetries - Maximum number of retries while attempting resolve the parition. + // MaxPartitionResolutionRetries - Maximum number of retries while attempting resolve the partition. MaxPartitionResolutionRetries *int32 `json:"maxPartitionResolutionRetries,omitempty"` // ManagementEndpoints - The cluster management endpoint. ManagementEndpoints *[]string `json:"managementEndpoints,omitempty"` @@ -3240,6 +3240,13 @@ type ConnectivityStatusContract struct { LastStatusChange *date.Time `json:"lastStatusChange,omitempty"` } +// CurrentUserIdentity ... +type CurrentUserIdentity struct { + autorest.Response `json:"-"` + // ID - API Management service user id. + ID *string `json:"id,omitempty"` +} + // DeployConfigurationParameters parameters supplied to the Deploy Configuration operation. type DeployConfigurationParameters struct { // Branch - The name of the Git branch from which the configuration is to be deployed to the configuration database. @@ -5277,18 +5284,83 @@ func (ic *IssueContract) UnmarshalJSON(body []byte) error { return nil } +// IssueContractBaseProperties issue contract Base Properties. +type IssueContractBaseProperties struct { + // CreatedDate - Date and time when the issue was created. + CreatedDate *date.Time `json:"createdDate,omitempty"` + // State - Status of the issue. Possible values include: 'Proposed', 'Open', 'Removed', 'Resolved', 'Closed' + State State `json:"state,omitempty"` + // APIID - A resource identifier for the API the issue was created for. + APIID *string `json:"apiId,omitempty"` +} + // IssueContractProperties issue contract Properties. type IssueContractProperties struct { // Title - The issue title. Title *string `json:"title,omitempty"` // Description - Text describing the issue. Description *string `json:"description,omitempty"` + // UserID - A resource identifier for the user created the issue. + UserID *string `json:"userId,omitempty"` // CreatedDate - Date and time when the issue was created. CreatedDate *date.Time `json:"createdDate,omitempty"` // State - Status of the issue. Possible values include: 'Proposed', 'Open', 'Removed', 'Resolved', 'Closed' State State `json:"state,omitempty"` + // APIID - A resource identifier for the API the issue was created for. + APIID *string `json:"apiId,omitempty"` +} + +// IssueUpdateContract issue update Parameters. +type IssueUpdateContract struct { + // IssueUpdateContractProperties - Issue entity Update contract properties. + *IssueUpdateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for IssueUpdateContract. +func (iuc IssueUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if iuc.IssueUpdateContractProperties != nil { + objectMap["properties"] = iuc.IssueUpdateContractProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IssueUpdateContract struct. +func (iuc *IssueUpdateContract) 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 "properties": + if v != nil { + var issueUpdateContractProperties IssueUpdateContractProperties + err = json.Unmarshal(*v, &issueUpdateContractProperties) + if err != nil { + return err + } + iuc.IssueUpdateContractProperties = &issueUpdateContractProperties + } + } + } + + return nil +} + +// IssueUpdateContractProperties issue contract Update Properties. +type IssueUpdateContractProperties struct { + // Title - The issue title. + Title *string `json:"title,omitempty"` + // Description - Text describing the issue. + Description *string `json:"description,omitempty"` // UserID - A resource identifier for the user created the issue. UserID *string `json:"userId,omitempty"` + // CreatedDate - Date and time when the issue was created. + CreatedDate *date.Time `json:"createdDate,omitempty"` + // State - Status of the issue. Possible values include: 'Proposed', 'Open', 'Removed', 'Resolved', 'Closed' + State State `json:"state,omitempty"` // APIID - A resource identifier for the API the issue was created for. APIID *string `json:"apiId,omitempty"` } diff --git a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/user.go b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/user.go index 0fa4d3ac8d98..2c17e936e054 100644 --- a/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/user.go +++ b/services/preview/apimanagement/mgmt/2018-06-01-preview/apimanagement/user.go @@ -529,6 +529,91 @@ func (client UserClient) GetEntityTagResponder(resp *http.Response) (result auto return } +// GetIdentity returns calling user identity information. +// Parameters: +// resourceGroupName - the name of the resource group. +// serviceName - the name of the API Management service. +func (client UserClient) GetIdentity(ctx context.Context, resourceGroupName string, serviceName string) (result CurrentUserIdentity, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UserClient.GetIdentity") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: serviceName, + Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("apimanagement.UserClient", "GetIdentity", err.Error()) + } + + req, err := client.GetIdentityPreparer(ctx, resourceGroupName, serviceName) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetIdentity", nil, "Failure preparing request") + return + } + + resp, err := client.GetIdentitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetIdentity", resp, "Failure sending request") + return + } + + result, err = client.GetIdentityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "apimanagement.UserClient", "GetIdentity", resp, "Failure responding to request") + } + + return +} + +// GetIdentityPreparer prepares the GetIdentity request. +func (client UserClient) GetIdentityPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "serviceName": autorest.Encode("path", serviceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-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.ApiManagement/service/{serviceName}/identity", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetIdentitySender sends the GetIdentity request. The method will close the +// http.Response Body if it receives an error. +func (client UserClient) GetIdentitySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetIdentityResponder handles the response to the GetIdentity request. The method always +// closes the http.Response Body. +func (client UserClient) GetIdentityResponder(resp *http.Response) (result CurrentUserIdentity, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // GetSharedAccessToken gets the Shared Access Authorization Token for the User. // Parameters: // resourceGroupName - the name of the resource group.