public GraphQLMethod(GraphQLMethodType methodType, string methodName, GraphQLParameters parameters = null, string[] fields = null) { MethodType = methodType; MethodName = methodName; Parameters = parameters; Fields = fields; }
/// <summary> /// Allows updating the properties of a snapshot schedule template /// /// <para> /// Allows updating of snapshot schedule template properties. Snapshot /// schedule templates are used to consistently provision snapshot /// schedules across nPods. They are referenced in nPod templates and /// are provisioned when a nPod is formed from such a template. /// </para> /// </summary> /// <param name="guid"> /// The unique identifier of the snapshot schedule template to update /// </param> /// <param name="name"> /// Human readable name for the snapshot schedule template /// </param> /// <param name="namePattern"> /// A naming pattern for volume snapshot names when they are /// automatically created. Available variables for the format string /// are from the standard <c>strftime</c> function. Additionally /// <c>%v</c> is used for the base volume name. /// </param> /// <param name="schedule"> /// The schedule by which volume snapshots will be created /// </param> /// <param name="expirationSeconds"> /// A time in seconds when snapshots will be automatically deleted. If /// not specified, snapshots will not be deleted automatically (not /// recommended) /// </param> /// <param name="retentionSeconds"> /// A time in seconds that prevents users from deleting snapshots. If /// not specified, snapshots can be immediately deleted. /// </param> /// <param name="ignoreBootVolumes"> /// Allows specifying if boot volumes shall be included when doing /// snapshots (<c>true</c>) or if they shall be ignored (<c>false</c>). /// By default, all volumes are included. /// </param> /// <returns></returns> public SnapshotScheduleTemplate UpdateSnapshotScheduleTemplate( Guid guid, string name = null, string namePattern = null, ScheduleInput schedule = null, long?expirationSeconds = null, long?retentionSeconds = null, bool?ignoreBootVolumes = null) { UpdateSnapshotScheduleTemplateInput input = new UpdateSnapshotScheduleTemplateInput(); input.Name = name; input.NamePattern = namePattern; input.Schedule = schedule; input.ExpirationSeconds = expirationSeconds; input.RetentionSeconds = retentionSeconds; input.IgnoreBootVolume = ignoreBootVolumes; // perpare parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("uuid", guid, false); parameters.Add("input", input, false); return(RunMutation <SnapshotScheduleTemplate>( @"updateSnapshotScheduleTemplate", parameters )); }
/// <summary> /// Allows creation of a new LUN /// /// <para> /// Allows the creation of a LUN for a volume.A LUN is an instance of a /// volume export that makes a volume accessible to a host. /// </para> /// <para> /// At least one host must be specified via <c>HostGuids</c> or /// <c>SpuSerials</c> - either one option must be specified but not /// both. If the <c>Locak</c> option is provided and set to <c>true</c> /// then the volume will be exported with ALUA, otherwise with ALUA /// turned off. /// </para> /// </summary> /// <param name="input"> /// An input definition for the new LUN. Review the CreateLunInput /// properties for configuration details /// </param> /// <returns>The new LUN if successful</returns> public Lun CreateLun(CreateLunInput input) { GraphQLParameters parameters = new GraphQLParameters(); parameters.Add(@"input", input); TokenResponse token = RunMutation <TokenResponse>(@"createLUN", parameters); if (!DeliverToken(token)) { throw new Exception("Token delivery failed"); } // wait until the new LUN is reporting in nebulon ON Thread.Sleep(TOKEN_WAITTIME_MS); // Query for LUN LunFilter filter = new LunFilter(); filter.LunGuid = new GuidFilter(); filter.LunGuid.MustEqual = token.WaitOn; LunList lunList = GetLuns(null, filter, null); if (lunList.FilteredCount != 1) { throw new Exception("Unexpected number of results returned"); } return(lunList.Items[0]); }
/// <summary> /// Allows replacing an SPU /// /// <para> /// The replace services processing unit (SPU) operation is used to /// transition the configuration of an old, likely failed, SPU to a new /// replacement unit and allows modifying the configuration during the /// process. /// </para> /// </summary> /// <param name="nPodGuid"> /// The unique identifier of the nPod of the old SPU that is being /// replaced /// </param> /// <param name="previousSpuSerial"> /// The serial number of the old SPU that is being replaced /// </param> /// <param name="newSpuInfo"> /// Configuration information for the new SPU /// </param> /// <param name="sSetGuid"> /// The storage set information for the existing SPU. This information /// can be obtained from the active replacement alert and only used to /// verify that the correct SPU is selected. /// </param> /// <returns></returns> public bool ReplaceSpu( Guid nPodGuid, string previousSpuSerial, NPodSpuInput newSpuInfo, Guid sSetGuid) { ReplaceSpuInput input = new ReplaceSpuInput(); input.NewSpuInfo = newSpuInfo; input.NPodGuid = nPodGuid; input.PreviousSpuSerial = previousSpuSerial; input.SsetGuid = sSetGuid; // prepare parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("input", input, false); TokenResponse tokenResponse = RunMutation <TokenResponse>( @"replaceSPU", parameters ); return(DeliverToken(tokenResponse)); }
/// <summary> /// Set a key value entry for a resource. /// /// <para> /// Allows adding metadata to various resources in nebulon ON in the form of /// key value pairs. This metadata can be used by customers to add arbitrary /// text information to resources that are not part of the default resource /// properties. /// </para> /// </summary> /// <param name="resourceType">Type of resource for the key value data</param> /// <param name="nPodGroupGuid">nPod Group identifier</param> /// <param name="resourceId">Identifier of the resource for the key value entry</param> /// <param name="key">Metadata key</param> /// <param name="value">Metadata value</param> /// <returns>Indicator if the query was successful</returns> public bool SetKeyValue( ResourceType resourceType, Guid nPodGroupGuid, string resourceId, string key, string value ) { // setup input UpsertKeyValueInput input = new UpsertKeyValueInput { ResourceType = resourceType, NPodGroupId = nPodGroupGuid, ResourceId = resourceId, Key = key, Value = value }; // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add(@"input", input); return(RunMutation <bool>(@"upsertKeyValue", parameters)); }
/// <summary> /// Allows deleting a nPod group object /// </summary> /// <param name="nPodGroupGuid"> /// The unique identifier of the nPod group to delete /// </param> /// <returns>If the deletion was a success</returns> public bool DeleteNPodGroup(Guid nPodGroupGuid) { GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("uuid", nPodGroupGuid, false); return(RunMutation <bool>("deleteNPodGroup", parameters)); }
/// <summary> /// Allows creating a new user in nebulon ON /// </summary> /// <param name="input"> /// The configuration for the new user /// </param> /// <returns>The new user</returns> public User CreateUser(CreateUserInput input) { GraphQLParameters parameters = new GraphQLParameters(); parameters.Add(@"input", input, false); return(RunMutation <User>(@"createOrgUser", parameters)); }
/// <summary> /// Allows deletion of a user account /// </summary> /// <param name="guid"> /// The unique identifier of the user that should be deleted /// </param> /// <returns>If the query was successful</returns> public bool DeleteUser(Guid guid) { GraphQLParameters parameters = new GraphQLParameters(); parameters.Add(@"uuid", guid); return(RunMutation <bool>(@"deleteOrgUser", parameters)); }
/// <summary> /// Retrieves the number of nPod groups matching the filter /// </summary> /// <param name="filter"> /// A filter object to filter the items on the server. If omitted, all /// items are counted on the server /// </param> /// <returns>The number of nPod groups matching the filter</returns> public long GetNPodGroupCount(NPodGroupFilter filter = null) { // setup query parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("filter", filter); return(RunQuery <long>("getNPodGroupCount", parameters)); }
/// <summary> /// Retrieves a list of recipes /// /// <para> /// Recipes are the result of mutations of mutations or modifications of /// on-premises infrastructure. As commands may require some time to /// complete, the recipe filter allows the query for their status. /// </para> /// </summary> /// <param name="filter"> /// A filter object to filter the nPod recipes on the server. If /// omitted, the server will return all objects as a paginated response. /// </param> /// <returns> /// A paginated list of nPod recipes /// </returns> public RecipeRecordList GetNPodRecipes(NPodRecipeFilter filter) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("filter", filter, false); return(RunQuery <RecipeRecordList>(@"getNPodRecipes", parameters)); }
/// <summary> /// Allows deletion of an RBAC policy object /// </summary> /// <param name="guid"> /// The unique identifier of the RBAC policy to delete /// </param> /// <returns>If the query was successful</returns> public bool DeleteRbacPolicy(Guid guid) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("uuid", guid, false); return(RunMutation <bool>(@"deleteRBACPolicy", parameters)); }
/// <summary> /// Get the number of users that match the specified filter /// </summary> /// <param name="filter"> /// A filter object to filter the user objects on the server. If /// omitted, the server will count all objects. /// </param> /// <returns></returns> public long GetUserCount(UserFilter filter = null) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("filter", filter, true); return(RunQuery <long>(@"getUsersCount", parameters)); }
/// <summary> /// Allows creation of a new support case /// </summary> /// <param name="supportCase"> /// A support case input object /// </param> /// <returns>The created support case</returns> public SupportCase CreateSupportCase(CreateSupportCaseInput supportCase) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("input", supportCase, true); return(RunMutation <SupportCase>(@"createSupportCase", parameters)); }
/// <summary> /// Retrieves a list of key value objects /// </summary> /// <param name="filter"> /// A filter object to filter key value objects on the /// server.If omitted, the server will return all objects as a /// paginated response. /// </param> /// <returns>A list of key value objects</returns> public KeyValueList GetKeyValues(KeyValueFilter filter) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("filter", filter); return(RunQuery <KeyValueList>(@"getKeyValues", parameters)); }
/// <summary> /// Create a new nPod template /// </summary> /// <param name="input"> /// An input object that describes the new nPod template /// </param> /// <returns>The created nPod template</returns> public NPodTemplate CreateNPodTemplate(CreateNPodTemplateInput input) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("input", input, true); return(RunMutation <NPodTemplate>(@"createNPodTemplate", parameters)); }
/// <summary> /// Allow updating properties of an existing user /// </summary> /// <param name="guid"> /// The unique identifier of the user that should be updated /// </param> /// <param name="input"> /// The updates for the user /// </param> /// <returns></returns> public User UpdateUser(Guid guid, UpdateUserInput input) { GraphQLParameters parameters = new GraphQLParameters(); parameters.Add(@"uuid", guid); parameters.Add(@"input", input); return(RunMutation <User>(@"updateOrgUser", parameters)); }
/// <summary> /// Allows deletion of an existing rack object /// /// <para> /// The deletion of a rack is only possible if the rack has no hosts /// (servers) associated. /// </para> /// </summary> /// <param name="rackGuid"> /// The unique identifier of the datacenter room to delete /// </param> /// <returns></returns> public bool DeleteRack(Guid rackGuid) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("uuid", rackGuid, false); return(RunMutation <bool>(@"deleteRack", parameters)); }
/// <summary> /// Allows deletion of a user group /// </summary> /// <param name="guid"> /// The unique identifier of the user group that should be deleted /// </param> /// <returns>If the query was successful</returns> public bool DeleteNebUserGroup(Guid guid) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add(@"uuid", guid, false); return(RunMutation <bool>(@"deleteOrgUserGroup", parameters)); }
/// <summary> /// Login to nebulon ON /// </summary> /// <param name="username">User name</param> /// <param name="password">Password</param> /// <returns>Login request result</returns> public LoginResults Login(string username, string password) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add(@"username", username); parameters.Add(@"password", password); return(RunMutation <LoginResults>(@"login", parameters)); }
/// <summary> /// Runs diagnostics before an update is installed /// /// <para> /// Ensures that an nPod is in a healthy state and that there are no /// issues preventing a successful update. /// </para> /// </summary> /// <param name="nPodGuid"> /// The unique identifier of the nPod for which the update pre-check /// is performed /// </param> /// <param name="packageName"> /// The package name to be installed /// </param> /// <returns> /// A list of warnings and errors discovered during the pre-check /// </returns> private Issues RunUpdatePreCheck(Guid nPodGuid, string packageName) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add(@"podUID", nPodGuid, false); parameters.Add(@"packageName", packageName, false); return(RunMutation <Issues>(@"updatePrecheck", parameters)); }
/// <summary> /// Delete an existing nPod template tree /// /// <para> /// This deletes an nPod template and all associated versions will /// become unavailable for nPod provisioning if the <c>ParentGuid</c> /// is supplied, otherwise the specific version is deleted. /// </para> /// </summary> /// <param name="nPodTemplateGuid"> /// The unique identifier of the nPod template tree. The <c>ParentGuid</c> /// property of the nPod template should be used for deletion. /// </param> /// <returns></returns> public bool DeleteNPodTemplate(Guid nPodTemplateGuid) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("parentUUID", nPodTemplateGuid, true); // run mutation return(RunMutation <bool>(@"deleteNPodTemplate", parameters)); }
/// <summary> /// Allows updating an existing support case /// </summary> /// <param name="number"> /// The case number of the support case to update /// </param> /// <param name="supportCase"> /// An input object that describes all fields to update /// </param> /// <returns>The updated support case</returns> public SupportCase UpdateSupportCase(string number, CreateSupportCaseInput supportCase) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("caseNumber", number, true); parameters.Add("input", supportCase, true); return(RunMutation <SupportCase>(@"updateSupportCase", parameters)); }
/// <summary> /// Allows deletion of a LUN /// </summary> /// <param name="lunGuid"> /// The unique identifier of the LUN to delete /// </param> /// <returns>If the deletion was a success</returns> public bool DeleteLun(Guid lunGuid) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("uuid", lunGuid); TokenResponse token = RunMutation <TokenResponse>("deleteLUN", parameters); return(DeliverToken(token)); }
/// <summary> /// Retrieves a list of SPUs /// </summary> /// <param name="page"> /// The requested page from the server. This is an optional argument /// and if omitted the server will default to returning the first page /// with a maximum of <c>100</c> items. /// </param> /// <param name="filter"> /// A filter object to filter the SPUs on the server. If omitted, the /// server will return all objects as a paginated response. /// </param> /// <param name="sort"> /// A sort definition object to sort the SPU objects on supported /// properties. If omitted objects are returned in the order as they /// were created in. /// </param> /// <returns></returns> public SpuList GetSpus(PageInput page = null, SpuFilter filter = null, SpuSort sort = null) { // prepare parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("page", page, true); parameters.Add("filter", filter, true); parameters.Add("sort", sort, true); return(RunQuery <SpuList>(@"getSPUs", parameters)); }
/// <summary> /// Allows creation of an on-demand snapshot of volumes /// <para> /// If multiple volumes are provided, multiple name patterns are /// required, where the index of the list of items are related. For /// example, the name pattern at index <c>3</c> of the /// <c>namePatterns</c> parameter will be applied to the volume /// specified at index <c>3</c> of the <c>parentVolumeGuids</c> list. /// </para> /// </summary> /// <param name="parentVolumeGuids"> /// List of unique identifiers for all volumes for which to create a /// snapshot /// </param> /// <param name="namePatterns"> /// List of naming patterns for volume snapshots. Options of the /// <c>strftime</c> function are available to format time and the /// variable <c>%v</c> that will be translated to the volume name. /// </param> /// <param name="expirationSeconds"> /// The number of seconds after snapshot creation when the snapshots /// will be automatically deleted /// </param> /// <param name="retentionSeconds"> /// The number of seconds before a user can delete the snapshots. /// </param> /// <returns></returns> public Volume CreateSnapshot( Guid[] parentVolumeGuids, string[] namePatterns, long?expirationSeconds = null, long?retentionSeconds = null) { // prepare parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("parentVvUID", parentVolumeGuids, false); parameters.Add("snapNamePattern", namePatterns, false); parameters.Add("consistencyLevel", SnapshotConsistencyLevel.VV, false); parameters.Add("roSnap", true, false); parameters.Add("expirationSec", expirationSeconds, false); parameters.Add("retentionSec", retentionSeconds, false); TokenResponse tokenResponse = RunMutation <TokenResponse>( @"createSnap", parameters); bool deliverySuccess = DeliverToken(tokenResponse); if (!deliverySuccess) { throw new Exception("Snapshot creation failed"); } // query for the snapshot VolumeFilter filter = new VolumeFilter(); filter.Guid = new GuidFilter(); filter.Guid.MustEqual = tokenResponse.WaitOn; DateTime start = DateTime.UtcNow; while (true) { Thread.Sleep(2000); VolumeList list = GetVolumes(null, filter, null); if (list.FilteredCount > 0) { return(list.Items[0]); } // check if we should time out. double duration = (DateTime.UtcNow - start).TotalSeconds; double remaining = SNAPSHOT_CREATE_WAITTIME_SEC - duration; if (remaining <= 0) { throw new Exception("Snapshot creation timed out"); } } }
/// <summary> /// Run a query against Nebulon ON. This function should be used when /// you expect just a single item returned. /// </summary> /// <typeparam name="T">The Type of the target array</typeparam> /// <param name="name">Name of the query</param> /// <param name="parameters">Parameters for the query</param> /// <returns>Single item returned by the query</returns> public T RunQuery <T>(string name, GraphQLParameters parameters = null) where T : new() { T[] results = RunQueryMany <T>(name, parameters); if (results.Length != 1) { throw new Exception("Unexpected number of results returned"); } return(results[0]); }
/// <summary> /// Allows uploading and attaching files to a support case /// </summary> /// <param name="number"> /// The case number of the support case to update /// </param> /// <param name="filePath"> /// The absolute path to the file to upload /// </param> /// <returns>The updated support case</returns> public SupportCase UploadSupportCaseAttachment(string number, string filePath) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("caseNumber", number, true); parameters.Add("attachment", filePath, true); throw new NotImplementedException("Currently not implemented"); // return RunMutation<SupportCase>(@"uploadSupportCaseAttachment", parameters); }
/// <summary> /// Retrieves a list of open alerts /// </summary> /// <param name="page"> /// The requested page from the server. This is an optional /// argument and if omitted the server will default to returning the /// first page with a maximum of <tt>100</tt> items. /// </param> /// <param name="filter"> /// A filter object to filter the open alerts on the /// server.If omitted, the server will return all objects as a /// paginated response. /// </param> /// <exception cref="Core.NebException"> /// An error with the GraphQL endpoint /// </exception> /// <returns>A paginated list of open alerts</returns> public AlertList GetOpenAlerts( PageInput page = null, AlertFilter filter = null) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("page", page, true); parameters.Add("filter", filter, true); return(RunQuery <AlertList>(@"getOpenAlerts", parameters)); }
/// <summary> /// Allows deletion of SPU information in nebulon ON /// </summary> /// <param name="spuSerial"> /// The serial number of the SPU /// </param> /// <returns></returns> public bool DeleteSpuInformation(string spuSerial) { // prepare parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("serial", spuSerial, true); return(RunMutation <bool>( @"delSPUInfo", parameters )); }
/// <summary> /// Retrieves a list of custom diagnostic command requests /// /// <para> /// Custom diagnostic command requests are used by customer satisfaction /// teams to run arbitrary troubleshooting commands on SPUs. These /// require user confirmation. /// </para> /// /// </summary> /// <param name="spuSerial"> /// The serial number for which to query for custom diagnostic command /// requests /// </param> /// <returns></returns> public SpuCustomDiagnostic[] GetSpuCustomDiagnostics(string spuSerial) { // prepare parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("spuSerial", spuSerial, true); return(RunQueryMany <SpuCustomDiagnostic>( @"spuCustomDiagnostics", parameters )); }