mirror of
https://github.com/octoleo/restic.git
synced 2024-11-15 01:34:06 +00:00
946c8399e2
Exclude minio-go for now (pin to 3.x.y).
288 lines
10 KiB
Go
Executable File
288 lines
10 KiB
Go
Executable File
package graphrbac
|
|
|
|
// Copyright (c) Microsoft and contributors. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
//
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
// Code generated by Microsoft (R) AutoRest Code Generator.
|
|
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
|
|
import (
|
|
"github.com/Azure/go-autorest/autorest"
|
|
"github.com/Azure/go-autorest/autorest/azure"
|
|
"github.com/Azure/go-autorest/autorest/validation"
|
|
"net/http"
|
|
)
|
|
|
|
// ObjectsClient is the the Graph RBAC Management Client
|
|
type ObjectsClient struct {
|
|
ManagementClient
|
|
}
|
|
|
|
// NewObjectsClient creates an instance of the ObjectsClient client.
|
|
func NewObjectsClient(tenantID string) ObjectsClient {
|
|
return NewObjectsClientWithBaseURI(DefaultBaseURI, tenantID)
|
|
}
|
|
|
|
// NewObjectsClientWithBaseURI creates an instance of the ObjectsClient client.
|
|
func NewObjectsClientWithBaseURI(baseURI string, tenantID string) ObjectsClient {
|
|
return ObjectsClient{NewWithBaseURI(baseURI, tenantID)}
|
|
}
|
|
|
|
// GetCurrentUser gets the details for the currently logged-in user.
|
|
func (client ObjectsClient) GetCurrentUser() (result AADObject, err error) {
|
|
req, err := client.GetCurrentUserPreparer()
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetCurrentUser", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.GetCurrentUserSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetCurrentUser", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetCurrentUserResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetCurrentUser", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetCurrentUserPreparer prepares the GetCurrentUser request.
|
|
func (client ObjectsClient) GetCurrentUserPreparer() (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"tenantID": autorest.Encode("path", client.TenantID),
|
|
}
|
|
|
|
const APIVersion = "1.6"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/{tenantID}/me", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// GetCurrentUserSender sends the GetCurrentUser request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client ObjectsClient) GetCurrentUserSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
|
|
}
|
|
|
|
// GetCurrentUserResponder handles the response to the GetCurrentUser request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ObjectsClient) GetCurrentUserResponder(resp *http.Response) (result AADObject, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// GetObjectsByObjectIds gets AD group membership for the specified AD object IDs.
|
|
//
|
|
// parameters is objects filtering parameters.
|
|
func (client ObjectsClient) GetObjectsByObjectIds(parameters GetObjectsParameters) (result GetObjectsResult, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: parameters,
|
|
Constraints: []validation.Constraint{{Target: "parameters.IncludeDirectoryObjectReferences", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIds")
|
|
}
|
|
|
|
req, err := client.GetObjectsByObjectIdsPreparer(parameters)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIds", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.GetObjectsByObjectIdsSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIds", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetObjectsByObjectIdsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIds", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetObjectsByObjectIdsPreparer prepares the GetObjectsByObjectIds request.
|
|
func (client ObjectsClient) GetObjectsByObjectIdsPreparer(parameters GetObjectsParameters) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"tenantID": autorest.Encode("path", client.TenantID),
|
|
}
|
|
|
|
const APIVersion = "1.6"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsJSON(),
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/{tenantID}/getObjectsByObjectIds", pathParameters),
|
|
autorest.WithJSON(parameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// GetObjectsByObjectIdsSender sends the GetObjectsByObjectIds request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client ObjectsClient) GetObjectsByObjectIdsSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
|
|
}
|
|
|
|
// GetObjectsByObjectIdsResponder handles the response to the GetObjectsByObjectIds request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ObjectsClient) GetObjectsByObjectIdsResponder(resp *http.Response) (result GetObjectsResult, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// GetObjectsByObjectIdsComplete gets all elements from the list without paging.
|
|
func (client ObjectsClient) GetObjectsByObjectIdsComplete(parameters GetObjectsParameters, cancel <-chan struct{}) (<-chan AADObject, <-chan error) {
|
|
resultChan := make(chan AADObject)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
defer func() {
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
list, err := client.GetObjectsByObjectIds(parameters)
|
|
if err != nil {
|
|
errChan <- err
|
|
return
|
|
}
|
|
if list.Value != nil {
|
|
for _, item := range *list.Value {
|
|
select {
|
|
case <-cancel:
|
|
return
|
|
case resultChan <- item:
|
|
// Intentionally left blank
|
|
}
|
|
}
|
|
}
|
|
for list.OdataNextLink != nil {
|
|
list, err = client.GetObjectsByObjectIdsNext(*list.OdataNextLink)
|
|
if err != nil {
|
|
errChan <- err
|
|
return
|
|
}
|
|
if list.Value != nil {
|
|
for _, item := range *list.Value {
|
|
select {
|
|
case <-cancel:
|
|
return
|
|
case resultChan <- item:
|
|
// Intentionally left blank
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// GetObjectsByObjectIdsNext gets AD group membership for the specified AD object IDs.
|
|
//
|
|
// nextLink is next link for the list operation.
|
|
func (client ObjectsClient) GetObjectsByObjectIdsNext(nextLink string) (result GetObjectsResult, err error) {
|
|
req, err := client.GetObjectsByObjectIdsNextPreparer(nextLink)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIdsNext", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.GetObjectsByObjectIdsNextSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIdsNext", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetObjectsByObjectIdsNextResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "graphrbac.ObjectsClient", "GetObjectsByObjectIdsNext", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetObjectsByObjectIdsNextPreparer prepares the GetObjectsByObjectIdsNext request.
|
|
func (client ObjectsClient) GetObjectsByObjectIdsNextPreparer(nextLink string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"nextLink": nextLink,
|
|
"tenantID": autorest.Encode("path", client.TenantID),
|
|
}
|
|
|
|
const APIVersion = "1.6"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/{tenantID}/{nextLink}", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// GetObjectsByObjectIdsNextSender sends the GetObjectsByObjectIdsNext request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client ObjectsClient) GetObjectsByObjectIdsNextSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
|
|
}
|
|
|
|
// GetObjectsByObjectIdsNextResponder handles the response to the GetObjectsByObjectIdsNext request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ObjectsClient) GetObjectsByObjectIdsNextResponder(resp *http.Response) (result GetObjectsResult, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|